本文介绍了如何解决 npm 安装错误“npm ERR!代码 1"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试安装 gulp,当我编写 npm install 时遇到了这个问题:

I'm trying to install gulp and when I write npm install I got this issue:

npm ERR! code 1
npm ERR! path D:wwwwegrow
ode_modules
ode-sass
npm ERR! command failed
npm ERR! command C:Windowssystem32cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:Program Files (x86)
odejs
ode.exe D:wwwwegrow
ode_modules
ode-gypin
ode-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli   'C:\Program Files (x86)\nodejs\node.exe',
npm ERR! gyp verb cli   'D:\www\wegrow\node_modules\node-gyp\bin\node-gyp.js',
npm ERR! gyp verb cli   'rebuild',
npm ERR! gyp verb cli   '--verbose',
npm ERR! gyp verb cli   '--libsass_ext=',
npm ERR! gyp verb cli   '--libsass_cflags=',
npm ERR! gyp verb cli   '--libsass_ldflags=',
npm ERR! gyp verb cli   '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.1.0 | win32 | ia32
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:wwwwegrow
ode_moduleswhichwhich.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:wwwwegrow
ode_moduleswhichwhich.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:wwwwegrow
ode_moduleswhichwhich.js:80:29)
npm ERR! gyp verb `which` failed     at D:wwwwegrow
ode_moduleswhichwhich.js:89:16
npm ERR! gyp verb `which` failed     at D:wwwwegrow
ode_modulesisexeindex.js:42:5
npm ERR! gyp verb `which` failed     at D:wwwwegrow
ode_modulesisexewindows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:194:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (D:wwwwegrow
ode_moduleswhichwhich.js:13:12)
npm ERR! gyp verb `which` failed     at F (D:wwwwegrow
ode_moduleswhichwhich.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:wwwwegrow
ode_moduleswhichwhich.js:80:29)
npm ERR! gyp verb `which` failed     at D:wwwwegrow
ode_moduleswhichwhich.js:89:16
npm ERR! gyp verb `which` failed     at D:wwwwegrow
ode_modulesisexeindex.js:42:5
npm ERR! gyp verb `which` failed     at D:wwwwegrow
ode_modulesisexewindows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:194:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python C:Python39python.EXE
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: C:Python39python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "<string>", line 1
npm ERR! gyp ERR! stack     import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack                       ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack     at ChildProcess.exithandler (node:child_process:326:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:365:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1067:16)
npm ERR! gyp ERR! stack     at Socket.<anonymous> (node:internal/child_process:453:11)
npm ERR! gyp ERR! stack     at Socket.emit (node:events:365:28)
npm ERR! gyp ERR! stack     at Pipe.<anonymous> (node:net:661:12)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\Program Files (x86)\nodejs\node.exe" "D:\www\wegrow\node_modules\node-gyp\bin\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd D:wwwwegrow
ode_modules
ode-sass
npm ERR! gyp ERR! node -v v16.1.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UserswbaluAppDataLocal
pm-cache\_logs2021-05-05T10_38_29_779Z-debug.log

我已经格式化了我的电脑.之前一切正常.现在,当我尝试安装它时,弹出的就是这个.我曾尝试重新安装 node.js,但没有帮助.我不知道该怎么办.

I have formatted my computer. Everything was working before. And now when I try to install it, that's what pops-up. I have tried reinstalling node.js but it didn't help. I don't know what should I do.

推荐答案

如果您的 Node 版本非常新,请尝试降级.稳定版 14.16.1 工作正常.

If your Node version is very recent, try downgrading. Stable version 14.16.1 worked.

这篇关于如何解决 npm 安装错误“npm ERR!代码 1"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-19 05:05