繁体   English   中英

运行 npm 安装给了我这些错误

[英]running npm install gives me these errors

I have tried a lot of things in order to fix this but can t find a solution, installed node sass that just added more problems, it used to run without a problem now I keep getting errors

npm ERR! code 1
    npm ERR! path D:\sb-app\node_modules\node-sass
    npm ERR! command failed
    npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js
    npm ERR! Building: C:\Program Files\nodejs\node.exe D:\sb-app\node_modules\node-gyp\bin\node-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\\nodejs\\node.exe',
    npm ERR! gyp verb cli   'D:\\sb-app\\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.2.0 | win32 | x64
    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:\sb-app\node_modules\which\which.js:13:12)
    npm ERR! gyp verb `which` failed     at F (D:\sb-app\node_modules\which\which.js:68:19)
    npm ERR! gyp verb `which` failed     at E (D:\sb-app\node_modules\which\which.js:80:29)
    npm ERR! gyp verb `which` failed     at D:\sb-app\node_modules\which\which.js:89:16
    npm ERR! gyp verb `which` failed     at D:\sb-app\node_modules\isexe\index.js:42:5
    npm ERR! gyp verb `which` failed     at D:\sb-app\node_modules\isexe\windows.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:\sb-app\node_modules\which\which.js:13:12)
    npm ERR! gyp verb `which` failed     at F (D:\sb-app\node_modules\which\which.js:68:19)
    npm ERR! gyp verb `which` failed     at E (D:\sb-app\node_modules\which\which.js:80:29)
    npm ERR! gyp verb `which` failed     at D:\sb-app\node_modules\which\which.js:89:16
    npm ERR! gyp verb `which` failed     at D:\sb-app\node_modules\isexe\index.js:42:5
    npm ERR! gyp verb `which` failed     at D:\sb-app\node_modules\isexe\windows.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:\Python39\python.EXE
    npm ERR! gyp ERR! configure error
    npm ERR! gyp ERR! stack Error: Command failed: C:\Python39\python.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 Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
    npm ERR! gyp ERR! System Windows_NT 10.0.19042
    npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\sb-app\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
    npm ERR! gyp ERR! cwd D:\sb-app\node_modules\node-sass
    npm ERR! gyp ERR! node -v v16.2.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:\Users\Ionutz\AppData\Local\npm-cache\_logs\2021-05-21T08_51_40_333Z-debug.log

我不知道该怎么做我也尝试安装 node-sass 但没有用

我有一个类似的问题。 尝试删除 package-lock.json 然后重新运行“npm install”。

npm 错误有时可能非常(可以说,过度)冗长。 错误的有趣部分是:

npm ERR! gyp verb check python checking for Python executable "python2" in the PATH

您尝试安装的 package 具有使用 gyp 在本地编译的本机部分,作为其工具的一部分,npm 需要 python2 来执行构建。
您需要确保已安装 python2,并且可执行文件是路径的一部分。

或者,如果您安装了 python 但名称不同,您可以通过调用告诉 npm 要使用哪个可执行文件

npm config set python /path/to/your/python

我昨天有一个类似的问题。 我通过确保在默认目录中下载了 python 并安装 Windows 构建工具来修复它,因为 node-sass 需要 node-gyp 而反过来需要 Windows 构建工具。

您可以使用管理员 shell 下载它,但 go 到此页面同样容易,然后找到并下载“Visual Studio 构建工具”。 这里也可以找到一个很好的视频来解释这个过程。 如前所述,您可以使用 powershell 安装它,前提是它以管理员身份运行,这个过程可以在它的 npm 页面上找到

完成此操作后,可能值得删除您的节点模块文件夹并重新运行 npm 安装。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM