当前位置:   article > 正文

Webstorm克隆Git后npm install报错_webstorm npm install

webstorm npm install

解决此问题浏览了网上众多方法,现已解决,留作记录(仅适合本文情况)。

一、Git克隆

在git克隆代码后,需要将右下角的分支由main签出为dev。
在这里插入图片描述在这里插入图片描述

二、npm install报错

npm ERR! code 1
npm ERR! path D:\workapp\Webstorm\work\yiwei_admin\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:\workapp\Webstorm\work\yiwei_admin\node_modules\node-gyp\bin\node-gyp.js reb
uild --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:\\workapp\\Webstorm\\work\\yiwei_admin\\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.16.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:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:13:12) 
npm ERR! gyp verb `which` failed     at F (D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\workapp\Webstorm\work\yiwei_admin\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\workapp\Webstorm\work\yiwei_admin\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 (D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:13:12) 
npm ERR! gyp verb `which` failed     at F (D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\workapp\Webstorm\work\yiwei_admin\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\workapp\Webstorm\work\yiwei_admin\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 (D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:13:12) 
npm ERR! gyp verb `which` failed     at F (D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\workapp\Webstorm\work\yiwei_admin\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\workapp\Webstorm\work\yiwei_admin\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 (D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:13:12) 
npm ERR! gyp verb `which` failed     at F (D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed     at E (D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed     at D:\workapp\Webstorm\work\yiwei_admin\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed     at D:\workapp\Webstorm\work\yiwei_admin\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed     at D:\workapp\Webstorm\work\yiwei_admin\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 (D:\workapp\Webstorm\work\yiwei_admin\node_modules\node-gyp\lib\configure
.js:484:19)
npm ERR! gyp ERR! stack     at PythonFinder.<anonymous> (D:\workapp\Webstorm\work\yiwei_admin\node_modules\node-gyp\lib\configure.
js:509:16)
npm ERR! gyp ERR! stack     at callback (D:\workapp\Webstorm\work\yiwei_admin\node_modules\graceful-fs\polyfills.js:306:20)       
npm ERR! gyp ERR! stack     at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp ERR! System Windows_NT 10.0.19043
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\workapp\\Webstorm\\work\\yiwei_admin\\node_modules\\node-gyp\
\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd D:\workapp\Webstorm\work\yiwei_admin\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.16.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\EDY\AppData\Local\npm-cache\_logs\2022-10-27T07_13_52_936Z-debug-0.log

进程已结束,退出代码1
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 44
  • 45
  • 46
  • 47
  • 48
  • 49
  • 50
  • 51
  • 52
  • 53
  • 54
  • 55
  • 56
  • 57
  • 58
  • 59
  • 60
  • 61
  • 62
  • 63
  • 64
  • 65
  • 66
  • 67
  • 68
  • 69
  • 70
  • 71
  • 72
  • 73
  • 74
  • 75
  • 76
  • 77
  • 78
  • 79
  • 80
  • 81
  • 82
  • 83
  • 84
  • 85

三、报错原因

package.json文件中dependencies依赖下,node-sass版本为4.14.1,所需node版本应为14,但当前node版本为16,故运行npm install报错。
在这里插入图片描述
在这里插入图片描述

四、解决办法

由于本地已经有一个版本16的node,所以需要安装nvm对node进行版本管理。
1、下载nvm
2、选择安装路径为之前已经安装node的文件路径!!!
3、在cmd命令行窗口中输入nvm -v提示安装版本即安装成功。
4、下载其他版本node(以管理员身份打开cmd ):

nvm list available
  • 1

查看可安装的NodeJS版本。(建议选择LTS中的版本进行安装)
在这里插入图片描述
然后根据需求安装需要的版本。

nvm install 14.20.1 
  • 1

nvm ls:列出所有已经在NVM中安装的NodeJS版本。

nvm current:显示当前正在使用的Node版本。

nvm use 14.20.1 :切换NodeJS版本 。

切换完node版本后再次运行npm install即可。

本文内容由网友自发贡献,转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/573907
推荐阅读
相关标签
  

闽ICP备14008679号