执行时出错 "create-react-app my-app"

Got an error while executing "create-react-app my-app"

我是 NodeJS 新手。 我已经执行了以下命令。 1.npm 安装-g create-react-app 2.create-react-app 我的应用程序

在执行第二个命令时我得到了这样的错误

正在安装软件包。这可能需要几分钟时间。 正在安装反应、反应-dom 和反应脚本...

uglifyjs-webpack-plugin@0.4.6 postinstall E:\Projects\HighAvenue\Dashboard\dashboard\node_modules\uglifyjs-webpack-plugin node lib/post_install.js

npm ERR! file bash npm ERR! path bash npm ERR! code ELIFECYCLE npm ERR! errno ENOENT npm ERR! syscall spawn bash npm ERR! uglifyjs-webpack-plugin@0.4.6 postinstall: node lib/post_install.js npm ERR! spawn bash ENOENT npm ERR! npm ERR! Failed at the uglifyjs-webpack-plugin@0.4.6 postinstall 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\Soorya\AppData\Roaming\npm-cache_logs18-06-26T05_00_45_645Z-debug.log

Aborting installation. npm install --save --save-exact --loglevel error react react-dom react-scripts has failed.

您是否有权在您尝试安装软件包的位置创建文件夹。如果您在语句之前使用 sudo 命令。

您可以使用具有管理员信任级别的 runas 命令执行此操作,或者右键单击 UI 中的程序并选择 "run as administrator."

谢谢

您的节点设置看起来不正确。这不是 Create React App 的问题——似乎你不能 运行 任何全局节点命令。

看起来 ~/.node_modules_global/bin 不在您的 PATH 环境变量中,因此它无法执行全局命令。 Bash 就是这样工作的——它无法猜测命令的位置,你需要告诉它。我假设 Node 安装应该默认执行此操作,但这取决于您安装 Node 的方式。

因此请确保该目录在您的 PATH 中,然后重试。如果您使用 Bash,请将其添加到您的 .profile 中,然后重新启动终端:

导出路径=$HOME/.node_modules_global/bin:$路径

谢谢大家的回复。 我在安装 yarn 后解决了这个问题。 谢谢