我正在尝试在我的反应应用程序中设置一个构建文件夹,但它无法编译。我希望运行“npm run build”并获得一个可以部署到我的服务器的构建包。当我尝试运行此命令时,出现以下错误:
npm run build
> paul-dill-portfolio@0.1.0 build C:\users\pdill\onedrive\documents\github\Dillweed5446.github.io
> react-scripts build
Creating an optimized production build...
Failed to compile.
./node_modules/react-icons/go/index.js
SyntaxError: C:\users\pdill\onedrive\documents\github\Dillweed5446.github.io\node_modules\react-icons\go\index.js: Support for the experimental syntax 'exportDefaultFrom' isn't currently enabled (1:8):
> 1 | export GoAlert from './alert';
| ^
2 | export GoAlignmentAlign from './alignment-align';
3 | export GoAlignmentAlignedTo from './alignment-aligned-to';
4 | export GoAlignmentUnalign from './alignment-unalign';
Add @babel/plugin-proposal-export-default-from (https://git.io/vb4yH) to the 'plugins' section of your Babel config to enable transformation.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! paul-dill-portfolio@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the paul-dill-portfolio@0.1.0 build 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\pdill\AppData\Roaming\npm-cache\_logs\2020-04-22T01_50_36_648Z-debug.log
此时,我尝试使用此处建议的“npm i @babel/plugin-proposal-export-default-from”命令手动安装@babel/plugin-proposal-export-default-from:
https://www.npmjs.com/package/@babel/plugin-proposal-export-default-from
当我尝试上述命令时,我收到以下错误消息:
npm i @babel/plugin-proposal-export-default-from
npm ERR! code ENOLOCAL
npm ERR! Could not install from "node_modules\@babel\plugult-from" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\pdill\AppData\Roaming\npm-cache\_lo253Z-debug.log
npm i @babel/plugin-proposal-export-default-from
npm ERR! code ENOLOCAL
npm ERR! Could not install from "node_modules\@babel\plugult-from" as it does not contain a package.json file.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\pdill\AppData\Roaming\npm-cache\_lo253Z-debug.log
此时,我为 plugin-proposal-export-default-from 创建了目录并添加了一个 package.json 文件。一旦我这样做了,我尝试了相同的命令,并得到了一个稍微不同的错误消息:
npm i @babel/plugin-proposal-export-default-from
npm ERR! Unexpected end of JSON input
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\pdill\AppData\Roaming\npm-cache\_lo898Z-debug.log
我不确定在这里还能做什么。最后,我只想运行“npm run build”,以便我可以将此应用程序部署到我的服务器和/或 github 上的托管站点。我试图跳过这一步并将所有文件上传到我的自托管站点(使用 cpanel),但由于 index.html 文件没有更新,我无法让它工作。我对如何更新 index.html 文件的理解是通过运行“npm run build”。对不起,如果这变得冗长。只是想给出一个很好的解释。谢谢你读到这里。