Advertisement

nvm_安装及注意事项

阅读量:

文章目录

  • nvm是什么

  • 下载

  • 安装/管理nodejs

  • 设置淘宝镜像源

  • npm install报错原因

    • 输入npm install 报错npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sass@4.13.1 postinstall: node scripts/build.js
    • Module build failed: Error: ENOENT: no such file or directory
    • 【Vue】“npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed.”
  • 参考

nvm是什么

nvm全名node.js version management,顾名思义是一个nodejs的版本管理工具。通过它可以安装和切换不同版本的nodejs。

下载

https://github.com/coreybutler/nvm-windows/releases
推荐使用nvm-setup.zip

解压安装,安装完成后 cmd窗口运行nvm命令,验证是否安装成功。

安装/管理nodejs

1。 查看本地安装的所有版本;有可选参数available,显示所有可下载的版本。

复制代码
    nvm list [available]
    nvm ls
    
    
    AI写代码bash
  1. 安装,命令中的版本号可自定义,具体参考命令1查询出来的列表
复制代码
    nvm install 10.15.0
    
    
    AI写代码bash
  1. 使用特定版本
复制代码
    nvm use 10.15.0
    
    
    AI写代码bash
  1. 卸载
复制代码
    nvm uninstall 10.15.0
    
    
    AI写代码bash

设置淘宝镜像源

  1. 打开nvm的安装路径
  2. 打开settings.txt,加入下面内容
复制代码
    arch: 64 
    proxy: none
    node_mirror: http://npm.taobao.org/mirrors/node/
    npm_mirror: https://npm.taobao.org/mirrors/npm/
    
    
    AI写代码bash

npm install报错原因

输入npm install 报错npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! node-sass@4.13.1 postinstall: node scripts/build.js

sass安装时获取源的问题,修改sass安装的源,使用taobao的npm

复制代码
    npm config set sass_binary_site=https://npm.taobao.org/mirrors/node-sass
    
    
    AI写代码bash

然后运行npm install

Module build failed: Error: ENOENT: no such file or directory

复制代码
    npm rebuild node-sass
    
    
    AI写代码bash

【Vue】“npm WARN ajv-keywords@3.2.0 requires a peer of ajv@^6.0.0 but none is installed.”

解决:手动安装ajv即可。

复制代码
    npm install ajv@^6.0.0
    
    
    AI写代码bash

参考

https://www.cnblogs.com/gaozejie/p/10689742.html
https://www.cnblogs.com/dengjerry/p/12686812.html
https://www.cnblogs.com/pxblog/p/12444050.html
<>
https://www.jianshu.com/p/a6948377a8a0

全部评论 (0)

还没有任何评论哟~