使用 react-static 构建站点时出现此错误:
C:/Users/.../test/artifacts/react-static-templates.js 1:1016 C:/Users/.../test/artifacts/react-static-templates.js 1:1016 中的错误模块解析失败:意外令牌 (1:1016) 您可能需要适当的加载程序来处理此文件类型。
该网站刚刚创建。我可以运行它,但我不能为部署而构建。
这似乎是 babel loader 的一个问题,但我对 react-static 架构的了解不够,无法修复它。
这里我认为可能相关的配置文件:
文件:.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"
}
}
环境:
- 节点: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