赞
踩
解决此问题浏览了网上众多方法,现已解决,留作记录(仅适合本文情况)。
在git克隆代码后,需要将右下角的分支由main签出为dev。
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
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
查看可安装的NodeJS版本。(建议选择LTS中的版本进行安装)
然后根据需求安装需要的版本。
nvm install 14.20.1
nvm ls
:列出所有已经在NVM中安装的NodeJS版本。
nvm current
:显示当前正在使用的Node版本。
nvm use 14.20.1
:切换NodeJS版本 。
切换完node版本后再次运行npm install即可。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。