我在用react static构建网站时遇到了这个错误:
错误 c:/.../test/test/fest-trifacts/react-static-templates.js 1:1016中的错误 c:/users/.../test/test/fastacts/react-static-templates.js 1:1016模块解析失败:意外令牌(1:1016)您可能需要一个 适当的加载程序来处理此文件类型。
刚刚创建了该网站。我可以运行它,但我不能为部署而构建。
这是Babel加载器的问题
在这里我认为配置文件可能相关:
文件:.babelrc
{
"presets": ["react-static/babel-preset.js"]
}
文件:.eslintrc.js
module.exports = {
extends: 'react-tools',
}
文件:package.json
{
"name": "react-static-example-basic",
"private": true,
"scripts": {
"start": "react-static start",
"stage": "react-static build --staging",
"build": "react-static build",
"bundle": "react-static bundle",
"export": "react-static export",
"serve": "serve dist -p 3000 -s"
},
"dependencies": {
"@reach/router": "^1.2.1",
"axios": "^0.18.0",
"react": "^16.8.1",
"react-dom": "^16.8.1",
"react-hot-loader": "^4.3.12",
"react-static": "^6.0.18"
},
"devDependencies": {
"eslint-config-react-tools": "1.x.x",
"serve": "10.1.1"
}
}
环境:
- nodejs:v10.15.3
- npm:6.9.0
- 反应静态:6.3.6
更新2019-03-16:
取得了淡淡的进步。发现这个封闭的问题与此错误完全匹配。
仍然,在应用修复程序后,静态模板的构建失败,但现在带有错误消息:
ERROR in .../artifacts/react-static-templates.js
Module build failed (from ./babel-loader/lib/index.js):
TypeError: Cannot read property 'replace' of undefined
我通过清洁nodejs环境并再次安装Mac上的问题。
。这里的步骤。也要看评论。评论可能还有几个步骤。