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
相关推荐
SomeB1oody29 分钟前
【RustyML入门】7.2. 深入模型持久化
开发语言·后端·机器学习·rust·教程
知几蜗牛29 分钟前
0 后端 · 0 数据库 · 0 备案:用 AI 两天搓出的股票管理系统,开源了
前端·后端·llm
yaoxin52112330 分钟前
502. Java 反射 - 编写 MessageInterceptor 类
java·开发语言
wuyk55534 分钟前
Python零基础入门第五章:元组Tuple(不可变容器详解、列表与元组区别)
开发语言·python
风流 少年34 分钟前
Spring AI 2.0:阿里云百炼平台(工作流应用)
java·后端·spring
2601_9657984741 分钟前
Build a Fast, High-Ranking Restaurant Website with Rolanda Theme
开发语言·ios·swift
__zRainy__44 分钟前
Node系列 · 数据库:单表查询
数据库·后端·mysql·node.js
caimouse1 小时前
ReactOS 窗口系统分析(25):标题栏显示与系统按钮 — nonclient.c 标题栏专题
c语言·开发语言
诺伦1 小时前
Rust 错误处理实战:从 unwrap 到优雅 Result 的进阶之路
开发语言·后端·rust
caimouse1 小时前
ReactOS 窗口系统分析(14):计时器/属性/加速键/热键 — timer.c + prop.c + accelerator.c + hotkey.c
c语言·开发语言·reactos