npm install 报错,帮忙看看

2021-12-01 22:33:06 +08:00
 idragonet
npm WARN deprecated @hapi/joi@15.1.1: Switch to 'npm install joi'
npm WARN deprecated axios@0.18.1: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410
npm WARN deprecated svgo@1.2.2: This SVGO version is no longer supported. Upgrade to v2.x.x.
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm WARN deprecated core-js@2.6.12: core-js@<3.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. Please, upgrade your dependencies to the actual version of core-js.
npm ERR! code 1
npm ERR! path E:\Vue\Vue8\OilStation-master\vue-OilStation\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 E:\Vue\Vue8\OilStation-master\vue-OilStation\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   'E:\\Vue\\Vue8\\OilStation-master\\vue-OilStation\\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.13.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 (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python2 Error: not found: python2
npm ERR! gyp verb `which` failed     at getNotFoundError (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198: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` failed Error: not found: python
npm ERR! gyp verb `which` failed     at getNotFoundError (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed  python Error: not found: python
npm ERR! gyp verb `which` failed     at getNotFoundError (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed     at F (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed   code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb could not find "python". checking python launcher
npm ERR! gyp verb could not find "python". guessing location
npm ERR! gyp verb ensuring that file exists: C:\Python27\python.exe
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack     at PythonFinder.failNoPython (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\node-gyp\lib\configure.js:484:19)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\node-gyp\lib\configure.js:509:16)
npm ERR! gyp ERR! stack     at callback (E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\graceful-fs\polyfills.js:299:20)
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp ERR! System Windows_NT 10.0.22000
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "E:\\Vue\\Vue8\\OilStation-master\\vue-OilStation\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd E:\Vue\Vue8\OilStation-master\vue-OilStation\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.13.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\longzhang\AppData\Local\npm-cache\_logs\2021-12-01T14_31_12_588Z-debug.log
2901 次点击
所在节点    Vue.js
15 条回复
Altschmerz
2021-12-01 22:36:31 +08:00
看这报错,是 python 执行路径没有找到,看看环境变量配置好了吗,或者安装 Windows-Build-Tools ,虽然 windows 自带 Windows-Build-Tools 。
ambiouss
2021-12-01 22:39:52 +08:00
update node-sass
liliclinton
2021-12-01 22:42:01 +08:00
不用这么麻烦,npm 版本大于 7 的话安装的时候带上 --legacy-peer-deps ,这样就不会安装 node-sass 了,如果一定需要就得配置下 node-gyp 的编译环境现场编译,这里报错是提示缺了 python2
codingBug
2021-12-01 22:47:37 +08:00
怎么感觉是需要翻墙的问题呢
yin1999
2021-12-01 23:00:23 +08:00
我感觉和楼上说的一致,试试设置环境变量 HTTP_PROXY 和 HTTPS_PROXY ,再 install
fzcf
2021-12-02 07:48:56 +08:00
node 和 npm 版本过高,换成 npm7.10.0 node v14.16.1
idragonet
2021-12-02 08:07:27 +08:00
@codingBug 已经配置代理了。
idragonet
2021-12-02 08:07:53 +08:00
@yin1999 已经配置梯子了。
BenchWidth
2021-12-02 08:59:06 +08:00
查看一下系统变量中有没有 %SystemRoot%\system32 这条变量,如果没有的话加上试试。
wequart
2021-12-02 09:18:26 +08:00
https://www.npmjs.com/package/node-sass
1. node-sass 有标注对应 node 版本应该下载的 node-sass 版本
2. 最好安装一个 windows-build-tools
3. 可以单独安装 node-sass 试试
DOLLOR
2021-12-02 10:13:36 +08:00
不用点进来就猜到 node-sass 这坑爹的玩意
YoRolling
2021-12-02 10:31:15 +08:00
1. node-sass 可以试试使用 taobao 的镜像服务
2. 可以试试单独装一个 Python 试试,前两天也帮人看了这个问题,没装 wbt ,直接装了个 Python 就可以了
3. node-sass 已经不推荐了,可以的话,请选择使用 dart-sass
rongchuan
2021-12-02 11:14:22 +08:00
这种情况只能试了。
1.试试 cnpm ,要用新的淘宝源
2.使用 nrm,切换不同的源试试
3.看看之前开发这项目的人用的 Node 版本是多少,用 nvm 切到一致的版本,在 npm i
4.装个 python 试试好使不,我印象中我之前有类似 bug ,装个 python 就好了
duan602728596
2021-12-02 11:19:52 +08:00
Sass 现在是这个: https://www.npmjs.com/package/sass
tmacLiu9527
2021-12-03 02:45:15 +08:00
1. 删除 node_modules
2. 管理员身份运行 npm install --global windows-build-tools
3. npm install

如果上述不行, 将 node-sass 升级到 5.0 或以上

参考:
https://fsou.cc/search?q=not%20found%3A%20python2
第一个 stackoverflow 帖子

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/819403

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX