NPM-使用React构建的网站无法构建

问题描述

我已经使用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 ]

解决方法

您好,请检查您的代码中是否还有多余的' / personal-site /处的

页面错误:语法错误:意外的令牌“

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...