node版本问题

服务器下载下来的vue项目启动出现下列问题

复制代码
npm ERR! path E:\vueEnv\app\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:\vueEnv\app\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:\\vueEnv\\app\\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@7.1.2
npm ERR! gyp info using node@18.17.1 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []

解决方法一

卸载 node-sass

复制代码
 npm uninstall node-sass
 #安装 node对应版本的
  npm i -D sass
  npm cache clean -f
  npm install
  npm serve

之后启动项目又遇到

set NODE_OPTIONS=--openssl-legacy-provider

npm run serve

#启动失败可能配置失败,再次设置

$env:NODE_OPTIONS="--openssl-legacy-provider"

npm run serve

方法二:

降低node版本 直接使用yarn启动

切换node版本

下载nvm管理包

复制代码
https://github.com/coreybutler/nvm-windows/releases

#查看当前版本号 nvm v 有说明安装成功

#输入nvm ls available查看当前版本号

安装命令 nvm install 16.17

使用命令nvm use 16.17

node 常用命令记录

复制代码
#npm更新到最新
npm install -g npm
#npm更新指定版本
npm install npm@7.24.2 -g 
#强制清楚缓存
npm cache clean -f
相关推荐
hugh_oo几秒前
100 天学会爬虫 · Day 11:如何合理控制爬虫请求频率?让访问行为更像真人
开发语言·爬虫·python
JIngJaneIL17 分钟前
基于java+ vue建筑材料管理系统(源码+数据库+文档)
java·开发语言·前端·数据库·vue.js·spring boot
一 乐19 分钟前
办公系统|基于springboot + vueOA办公管理系统(源码+数据库+文档)
java·数据库·vue.js·spring boot·后端·spring
半梅芒果干22 分钟前
vue3 新建文件store自动导入
开发语言·前端·javascript
Tony Bai23 分钟前
Go 1.26 新特性前瞻:从 Green Tea GC 到语法糖 new(expr),性能与体验的双重进化
开发语言·后端·golang
资源站shanxueit或com34 分钟前
Python入门教程:从零到实战的保姆级指南(避坑大全) 原创
后端
悟能不能悟34 分钟前
Java 中将 List 中对象的某一列转换为 Set
java·开发语言·list
越千年36 分钟前
工作中常用到的二进制运算
后端·go
vortex539 分钟前
Bash Shell 的展开与补全机制
开发语言·bash