npm install 报错,帮忙看看 - V2EX
V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
idragonet
V2EX    Vue.js

npm install 报错,帮忙看看

  •  
  •   idragonet 2021-12-01 22:33:06 +08:00 3420 次点击
    这是一个创建于 1412天前的主题,其中的信息可能已经有所发展或是发生改变。
    npm WARN deprecated @hapi/[email protected]: Switch to 'npm install joi' npm WARN deprecated [email protected]: Critical security vulnerability fixed in v0.21.1. For more information, see https://github.com/axios/axios/pull/3410 npm WARN deprecated [email protected]: This SVGO version is no longer supported. Upgrade to v2.x.x. 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.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 [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:\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 
    第 1 条附言    2021-12-08 11:57:31 +08:00
    谢谢各位回复。
    解决方法:
    package.json 剔除了 node-sass ,独立安装 node-sass 就行了:npm install node-sass
    15 条回复    2021-12-03 02:45:15 +08:00
    Altschmerz
        1
    Altschmerz  
       2021-12-01 22:36:31 +08:00
    看这报错,是 python 执行路径没有找到,看看环境变量配置好了吗,或者安装 Windows-Build-Tools ,虽然 windows 自带 Windows-Build-Tools 。
    ambiouss
        2
    ambiouss  
       2021-12-01 22:39:52 +08:00
    update node-sass
    liliclinton
        3
    liliclinton  
       2021-12-01 22:42:01 +08:00
    不用这么麻烦,npm 版本大于 7 的话安装的时候带上 --legacy-peer-deps ,这样就不会安装 node-sass 了,如果一定需要就得配置下 node-gyp 的编译环境现场编译,这里报错是提示缺了 python2
    codingBug
        4
    codingBug  
       2021-12-01 22:47:37 +08:00 via Android
    怎么感觉是需要翻墙的问题呢
    yin1999
        5
    yin1999  
       2021-12-01 23:00:23 +08:00 via Android
    我感觉和楼上说的一致,试试设置环境变量 HTTP_PROXY 和 HTTPS_PROXY ,再 install
    fzcf
        6
    fzcf  
       2021-12-02 07:48:56 +08:00
    node 和 npm 版本过高,换成 npm7.10.0 node v14.16.1
    idragonet
        7
    idragonet  
    OP
       2021-12-02 08:07:27 +08:00
    @codingBug 已经配置代理了。
    idragonet
        8
    idragonet  
    OP
       2021-12-02 08:07:53 +08:00
    @yin1999 已经配置梯子了。
    BenchWidth
        9
    BenchWidth  
       2021-12-02 08:59:06 +08:00
    查看一下系统变量中有没有 %SystemRoot%\system32 这条变量,如果没有的话加上试试。
    wequart
        10
    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 试试
    AV1
        11
    AV1  
       2021-12-02 10:13:36 +08:00
    不用点进来就猜到 node-sass 这坑爹的玩意
    YoRolling
        12
    YoRolling  
       2021-12-02 10:31:15 +08:00
    1. node-sass 可以试试使用 taobao 的镜像服务
    2. 可以试试单独装一个 Python 试试,前两天也帮人看了这个问题,没装 wbt ,直接装了个 Python 就可以了
    3. node-sass 已经不推荐了,可以的话,请选择使用 dart-sass
    rongchuan
        13
    rongchuan  
       2021-12-02 11:14:22 +08:00
    这种情况只能试了。
    1.试试 cnpm ,要用新的淘宝源
    2.使用 nrm,切换不同的源试试
    3.看看之前开发这项目的人用的 Node 版本是多少,用 nvm 切到一致的版本,在 npm i
    4.装个 python 试试好使不,我印象中我之前有类似 bug ,装个 python 就好了
    duan602728596
        14
    duan602728596  
       2021-12-02 11:19:52 +08:00
    Sass 现在是这个: https://www.npmjs.com/package/sass
    tmacLiu9527
        15
    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 帖子
    关于     帮助文档     自助推广系统     博客     API     FAQ     Solana     1087 人在线   最高记录 6679       Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 28ms UTC 18:12 PVG 02:12 LAX 11:12 JFK 14:12
    Do have faith in what you're doing.
    ubao snddm index pchome yahoo rakuten mypaper meadowduck bidyahoo youbao zxmzxm asda bnvcg cvbfg dfscv mmhjk xxddc yybgb zznbn ccubao uaitu acv GXCV ET GDG YH FG BCVB FJFH CBRE CBC GDG ET54 WRWR RWER WREW WRWER RWER SDG EW SF DSFSF fbbs ubao fhd dfg ewr dg df ewwr ewwr et ruyut utut dfg fgd gdfgt etg dfgt dfgd ert4 gd fgg wr 235 wer3 we vsdf sdf gdf ert xcv sdf rwer hfd dfg cvb rwf afb dfh jgh bmn lgh rty gfds cxv xcv xcs vdas fdf fgd cv sdf tert sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf sdf shasha9178 shasha9178 shasha9178 shasha9178 shasha9178 liflif2 liflif2 liflif2 liflif2 liflif2 liblib3 liblib3 liblib3 liblib3 liblib3 zhazha444 zhazha444 zhazha444 zhazha444 zhazha444 dende5 dende denden denden2 denden21 fenfen9 fenf619 fen619 fenfe9 fe619 sdf sdf sdf sdf sdf zhazh90 zhazh0 zhaa50 zha90 zh590 zho zhoz zhozh zhozho zhozho2 lislis lls95 lili95 lils5 liss9 sdf0ty987 sdft876 sdft9876 sdf09876 sd0t9876 sdf0ty98 sdf0976 sdf0ty986 sdf0ty96 sdf0t76 sdf0876 df0ty98 sf0t876 sd0ty76 sdy76 sdf76 sdf0t76 sdf0ty9 sdf0ty98 sdf0ty987 sdf0ty98 sdf6676 sdf876 sd876 sd876 sdf6 sdf6 sdf9876 sdf0t sdf06 sdf0ty9776 sdf0ty9776 sdf0ty76 sdf8876 sdf0t sd6 sdf06 s688876 sd688 sdf86