通过 NPM“spawn C:\Program ENOENT”安装赛普拉斯时出错

时间:2021-05-05 15:11:39

标签: node.js npm cypress npm-install

一天都无法克服这个错误,在线找不到可行的解决方案,请帮我看看我看不到的地方。我有两台相邻的笔记本电脑,一台完美地安装了 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

2 个答案:

答案 0 :(得分:0)

这个

<块引用>

生成 C:\Program ENOENT

看起来您在安装后有一个未加引号的路径。这可能应该是“C:\Program Files...”或“C:\Program Files (x86)...”。相反,它试图执行因 ENOENT 而失败的 C:\Program,因为它不存在。检查您的环境设置和您正在调用的脚本。

答案 1 :(得分:0)

问题在于 .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 文件解决了该问题。