windows系统nodeJs报错node-sass npm ERR! command failed

报错信息

npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm WARN deprecated [email protected]: core-js@<3.23.3 is no longer maintained and not recommended for usage due to the number of issues. Because of the V8 engine whims, feature detection in old core-js versions could cause a slowdown up to 100x even if nothing is polyfilled. Some versions have web compatibility issues. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! path E:\ideawork_my\时光序页面\records\node_modules\vue-mindmap\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: E:\ideawork_my\时光序页面\records\node_modules\node\bin\node.exe E:\ideawork_my\时光序页面\records\node_modules\vue-mindmap\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   'E:\\ideawork_my\\时光序页面\\records\\node_modules\\node\\bin\\node.exe',
npm ERR! gyp verb cli   'E:\\ideawork_my\\时光序页面\\records\\node_modules\\vue-mindmap\\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 [email protected]
npm ERR! gyp info using [email protected] | 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 (E:\ideawork_my\时光序页面\records\node_modules\vue-mindmap\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (E:\ideawork_my\时光序页面\records\node_modules\vue-mindmap\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (E:\ideawork_my\时光序页面\records\node_modules\vue-mindmap\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at E:\ideawork_my\时光序页面\records\node_modules\vue-mindmap\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at E:\ideawork_my\时光序页面\records\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at E:\ideawork_my\时光序页面\records\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:202:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (E:\ideawork_my\时光序页面\records\node_modules\vue-mindmap\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (E:\ideawork_my\时光序页面\records\node_modules\vue-mindmap\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (E:\ideawork_my\时光序页面\records\node_modules\vue-mindmap\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at E:\ideawork_my\时光序页面\records\node_modules\vue-mindmap\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at E:\ideawork_my\时光序页面\records\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at E:\ideawork_my\时光序页面\records\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:202: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 D:\Python\Python38\python.EXE
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: D:\Python\Python38\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack   File "", 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:402:12)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:513:28)
npm ERR! gyp ERR! stack     at maybeClose (node:internal/child_process:1100:16)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:304:5)
npm ERR! gyp ERR! System Windows_NT 10.0.22621
npm ERR! gyp ERR! command "E:\\ideawork_my\\时光序页面\\records\\node_modules\\node\\bin\\node.exe" "E:\\ideawork_my\\时光序页面\\records\\node_modules\\vue-mindmap\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd E:\ideawork_my\时光序页面\records\node_modules\vue-mindmap\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.20.2
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\dell\AppData\Local\npm-cache\_logs\2023-12-08T06_56_00_079Z-debug-0.log

以 python2.7安装

npm install node-sass --python=python2.7 
npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR!
npm ERR! While resolving: undefined@undefined
npm ERR! Found: [email protected]
npm ERR! node_modules/vue
npm ERR!   vue@"^3.3.4" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue@"^2.6.14" from @wangeditor/[email protected]
npm ERR! node_modules/@wangeditor/editor-for-vue
npm ERR!   @wangeditor/editor-for-vue@"^1.0.2" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See C:\Users\dell\AppData\Local\npm-cache\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\dell\AppData\Local\npm-cache\_logs\2023-12-08T07_02_58_989Z-debug-0.log

升级Node

https://nodejs.org/en/download/

windows系统nodeJs报错node-sass npm ERR! command failed_第1张图片
下载最新版本解压覆盖之前的版本

忘记之前在哪个位置 可通过 where node

安装cnpm

1、安装cnpm,输入以下命令:

npm install -g cnpm --registry=http://registry.npm.taobao.org

注意:为了避免每次安装都需要–registry参数,可以使用如下命令

进行永久设置:npm config set registry http://registry.npm.taobao.org

重新安装node-sass

根据报错信息 得出是node-sass的版本问题
更新 node-sass

node-sass和node的版本对照: https://www.npmjs.com/package/node-sass

后续参考:
https://blog.csdn.net/qq_37974755/article/details/124604371?utm_medium=distribute.pc_relevant.none-task-blog-2defaultbaidujs_baidulandingword~default-4-124604371-blog-133519851.235v39pc_relevant_default_base&spm=1001.2101.3001.4242.3&utm_relevant_index=7

或者

如果node是最新版本,则可以直接使用以下命令安装即可
npm install sass-loader node-sass --save-dev

cnpm install sass-loader node-sass --save-dev

如果node不是最新版本,则需要安装对应的版本号才行
npm install sass-loader@版本号 node-sass@版本号 --save-dev //安装对应的版本

cnpm install sass-loader@版本号 node-sass@版本号 --save-dev //安装对应的版本

卸载安装低版本Node

npm install –save-dev node-sass – force

https://www.iotword.com/16158.html

卸载python

根据报错信息

npm ERR! gyp verb `which` failed  python2 Error: not found: python2

可以执行以下命令试试
npm install node-sass --python=python2.7 --force

由于我本机python环境是3.8.4
一直报错找不到python2 索性卸载了 python

你可能感兴趣的:(windows,sass,npm)