文章摘要: 摘要内容。
下载速度太慢,更换为国内镜像源
相关信息
- 这是包管理工具,因此需要下载的第三方包都存放在别人管理的服务器仓库中。
- 有国外的仓库镜像源,也有国内的仓库镜像源,选择国内的可以提高下载速度。
- 更换为国内华为的npm镜像源
# 修改为华为镜像源
npm config set registry https://mirrors.huaweicloud.com/repository/npm/
# 清空缓存
npm cache clean -f
当需要全局安装时失败,没有写入权限
- 请先获取管理员权限后在运行。
注释
报错案例
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/@ionic
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@ionic'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/@ionic'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/@ionic'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2024-10-23T10_50_18_325Z-debug-0.log
如何很好的管理不同版本的NodeJS
- 通过配置文件解决环境问题
- ==待完善==
依赖包版本不同的问题解决方案
- 全部使用局部安装,通过
npm run命令来运行项目包中的命令。 - 需要在项目中的
package.json配置文件中的scripts属性里定义命令。