我已经使用 ReactJS 创建了一个网站,并且在我的本地机器上运行完美。但是当我运行npm run build
这是我得到的错误:
> react-snap
� pageerror at /personal-site/: SyntaxError: Unexpected token '<'
✅ crawled 1 out of 1 (/personal-site/)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! personal-site@2.1.0 postbuild: `react-snap`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the personal-site@2.1.0 postbuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\[MYUSERNAMEHERE]\AppData\Roaming\npm-cache\_logs\2020-08-24T04_04_29_334Z-debug.log
我打算将其部署到 github 页面。在我的 package.json 中,我有以下行作为主页:
"name": "personal-site",
"version": "2.1.0",
"homepage": "https://[MYUSERNAME].github.io/personal-site/",
请注意,个人站点是我的项目和存储库的名称。我还有一个.env
如下所示的文件:
NODE_ENV=production
PORT=7999
BASE_PATH=/personal-site/
这个错误的原因是什么?另外,我该如何克服这个错误?
以下是调试日志。[修剪]
...
24 verbose node v12.18.1
25 verbose npm v6.14.5
26 error code ELIFECYCLE
27 error errno 1
28 error personal-site@2.1.0 postbuild: `react-snap`
28 error Exit status 1
29 error Failed at the personal-site@2.1.0 postbuild script.
29 error This is probably not a problem with npm. There is likely additional logging output above.
30 verbose exit [ 1, true ]