通过 NPM 安装 Cypress 时出错 "spawn C:\Program ENOENT"
Error installing Cypress via NPM "spawn C:\Program ENOENT"
一天都无法克服这个错误,网上找不到可行的解决方案,请帮我看看我没有看到的。我有两台笔记本电脑并排放置,一台完美地安装了 nodejs 和 cypress,一台则抛出这种错误。尝试重新安装、卸载、更改 PATH 变量、不同版本的 nodejs、关闭和打开、重新启动,并在线寻找解决方案数小时。我不想直接下载 Cypress,我想以“正确的方式”下载。日志中的相关行:
1116 info run cypress@7.2.0 postinstall node_modules/cypress node index.js --exec install
1117 info run cypress@7.2.0 postinstall { code: 'ENOENT', signal: undefined }
1118 timing reify:rollback:createSparse Completed in 779ms
1119 timing reify:rollback:retireShallow Completed in 0ms
1120 timing command:install Completed in 5328ms
1121 verbose stack Error: spawn C:\Program ENOENT
1121 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
1121 verbose stack at onErrorNT (internal/child_process.js:465:16)
1121 verbose stack at processTicksAndRejections (internal/process/task_queues.js:80:21)
1122 verbose pkgid cypress@7.2.0
1123 verbose cwd C:\Users\sopkop\cypress_project
1124 verbose Windows_NT 10.0.19042
1125 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\sopkop\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "cypress"
1126 verbose node v14.16.1
1127 verbose npm v7.11.2
1128 error code ENOENT
1129 error syscall spawn C:\Program
1130 error path C:\Users\sopkop\cypress_project\node_modules\cypress
1131 error errno -4058
1132 error enoent spawn C:\Program ENOENT
1133 error enoent This is related to npm not being able to find a file.
1134 verbose exit -4058
这个
spawn C:\Program ENOENT
看起来您在 post 安装中有一个未加引号的路径。这可能应该是“C:\Program Files...”或“C:\Program Files (x86)...”。相反,它试图执行 C:\Program,但由于 ENOENT 不存在而失败。检查您的环境设置和您正在调用的脚本。
问题出在 .npmrc 文件中的用户配置。文件内容:
script-shell=C:\Program
Files\git\bin\bash.exe=
registry=http://registry.npmjs.org/
strict-ssl=false
proxy=null
https-proxy=null
不确定“script-shell=C:\Program”来自哪里,但删除 .npmrc 文件解决了这个问题。
一天都无法克服这个错误,网上找不到可行的解决方案,请帮我看看我没有看到的。我有两台笔记本电脑并排放置,一台完美地安装了 nodejs 和 cypress,一台则抛出这种错误。尝试重新安装、卸载、更改 PATH 变量、不同版本的 nodejs、关闭和打开、重新启动,并在线寻找解决方案数小时。我不想直接下载 Cypress,我想以“正确的方式”下载。日志中的相关行:
1116 info run cypress@7.2.0 postinstall node_modules/cypress node index.js --exec install
1117 info run cypress@7.2.0 postinstall { code: 'ENOENT', signal: undefined }
1118 timing reify:rollback:createSparse Completed in 779ms
1119 timing reify:rollback:retireShallow Completed in 0ms
1120 timing command:install Completed in 5328ms
1121 verbose stack Error: spawn C:\Program ENOENT
1121 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
1121 verbose stack at onErrorNT (internal/child_process.js:465:16)
1121 verbose stack at processTicksAndRejections (internal/process/task_queues.js:80:21)
1122 verbose pkgid cypress@7.2.0
1123 verbose cwd C:\Users\sopkop\cypress_project
1124 verbose Windows_NT 10.0.19042
1125 verbose argv "C:\Program Files\nodejs\node.exe" "C:\Users\sopkop\AppData\Roaming\npm\node_modules\npm\bin\npm-cli.js" "install" "cypress"
1126 verbose node v14.16.1
1127 verbose npm v7.11.2
1128 error code ENOENT
1129 error syscall spawn C:\Program
1130 error path C:\Users\sopkop\cypress_project\node_modules\cypress
1131 error errno -4058
1132 error enoent spawn C:\Program ENOENT
1133 error enoent This is related to npm not being able to find a file.
1134 verbose exit -4058
这个
spawn C:\Program ENOENT
看起来您在 post 安装中有一个未加引号的路径。这可能应该是“C:\Program Files...”或“C:\Program Files (x86)...”。相反,它试图执行 C:\Program,但由于 ENOENT 不存在而失败。检查您的环境设置和您正在调用的脚本。
问题出在 .npmrc 文件中的用户配置。文件内容:
script-shell=C:\Program
Files\git\bin\bash.exe=
registry=http://registry.npmjs.org/
strict-ssl=false
proxy=null
https-proxy=null
不确定“script-shell=C:\Program”来自哪里,但删除 .npmrc 文件解决了这个问题。