指尖上的记忆指尖上的记忆
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub
首页
  • 基础
  • Laravel框架
  • Symfony框架
  • 基础
  • Gin框架
  • 基础
  • Spring框架
  • 命令
  • Nginx
  • Ai
  • Deploy
  • Docker
  • K8s
  • Micro
  • RabbitMQ
  • Mysql
  • PostgreSsql
  • Redis
  • MongoDb
  • Html
  • Js
  • 前端
  • 后端
  • Git
  • 知识扫盲
  • Golang
🌟 gitHub

最近做项目,报node版本过低的问题:

vagrant@homestead:~/code/duoxiaozhan-www$ yarn install
yarn install v1.22.17
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
error @vue-macros/common@1.3.3: The engine "node" is incompatible with this module. Expected version ">=16.14.0". Got "14.19.0" //版本过低
error Found incompatible module.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.

升级nodeJs操作:
Node.js官方提供了一种命令行工具n,可以通过这个工具方便地升级到最新版本的Node.js。

  • 安装 n 命令
vagrant@homestead:~/code/duoxiaozhan-www$ sudo npm install n -g

added 1 package, and audited 2 packages in 7s

found 0 vulnerabilities
  • 安装要升级的版本
vagrant@homestead:~/code/duoxiaozhan-www$ sudo n latest //这里直接到最新版本,可以指定,比如: 18.1.0
  installing : node-v20.2.0
       mkdir : /usr/local/n/versions/node/20.2.0
       fetch : https://nodejs.org/dist/v20.2.0/node-v20.2.0-linux-x64.tar.xz
     copying : node/20.2.0
   installed : v20.2.0 (with npm 9.6.6)

Note: the node command changed location and the old location may be remembered in your current shell.
         old : /usr/bin/node
         new : /usr/local/bin/node
If "node --version" shows the old version then start a new shell, or reset the location hash with:
hash -r  (for bash, zsh, ash, dash, and ksh)
rehash   (for csh and tcsh)

注意上面的 Note,按照提示操作一遍即可解决问题,我直接新开一个terminal 然后执行 hash -r 即可