IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 开发工具 -> Webstorm克隆Git后npm install报错 -> 正文阅读

[开发工具]Webstorm克隆Git后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

三、报错原因

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即可。

  开发工具 最新文章
Postman接口测试之Mock快速入门
ASCII码空格替换查表_最全ASCII码对照表0-2
如何使用 ssh 建立 socks 代理
Typora配合PicGo阿里云图床配置
SoapUI、Jmeter、Postman三种接口测试工具的
github用相对路径显示图片_GitHub 中 readm
Windows编译g2o及其g2o viewer
解决jupyter notebook无法连接/ jupyter连接
Git恢复到之前版本
VScode常用快捷键
上一篇文章      下一篇文章      查看所有文章
加:2022-10-31 12:20:15  更:2022-10-31 12:21:35 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年12日历 -2024/12/28 3:18:20-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码
数据统计