• 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 []
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19

    在这里插入图片描述
    解决方法一
    卸载 node-sass

     npm uninstall node-sass
     #安装 node对应版本的
      npm i -D sass
      npm cache clean -f
      npm install
      npm serve
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    之后启动项目又遇到
    在这里插入图片描述
    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
    
    • 1

    #查看当前版本号 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
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
  • 相关阅读:
    设计模式——7. 装饰者模式
    【C++ Primer Plus】第1章 预备知识
    验证拦截器的执行流程
    Java递归算法
    计算机毕业设计Java智慧书籍的网站(源码+系统+mysql数据库+lw文档)
    【大数据采集工具-gobblin】
    玩一玩 Ubuntu 下的 VSCode 编程
    c#调用c++生成的dll,c++端使用opencv, c#端使用OpenCvSharp, 返回一张图像
    如何将PDF文件转换成Excel呢?
    计算机的总线
  • 原文地址:https://blog.csdn.net/weixin_50491125/article/details/132709481