npm i
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: @angular-devkit/[email protected]
npm ERR! Found: [email protected]
npm ERR! node_modules/tslint
npm ERR! dev tslint@"5.15.0" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional tslint@"^6.1.0" from @angular-devkit/[email protected]
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~12.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: [email protected]
npm ERR! node_modules/tslint
npm ERR! peerOptional tslint@"^6.1.0" from @angular-devkit/[email protected]
npm ERR! node_modules/@angular-devkit/build-angular
npm ERR! dev @angular-devkit/build-angular@"~12.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
因为版本冲突,所以angular安装失败,所以用npm install -g @angular/[email protected] 全局安装angular 特定的版本12.0.0 ,安装成功以后用 npm install --save --legacy-peer-deps 安装npm,问题就解决了。
这个是我再解决这个问题的过程中用到的命令。
Nodejs版本16
cmd
npm -v #查看npm的版本
node -v #查看nodejs的版本
npm config set proxy=http://账号:密码@服务器名:端口号http://账号:密码@
npm config set https-proxy=http://账号:密码@服务器名:端口号@
npm config get cache #详情参照网页:https://newsn.net/say/npm-cache.html
npm cache clean #清除缓存#详情参照网页:https://newsn.net/say/npm-cache.html
npm cache clean -f #强制清除缓存#详情参照网页:https://newsn.net/say/npm-cache.html
npm install -g @angular/[email protected] #全局安装angular 特定的版本12.0.0
npm install --save --legacy-peer-deps #强制安装npm #只是在系统部署,或者有新的安装包需要安装的时候执行
ng serve #用angular启动程序#
注:8若报此错误C:\Users\xxx\AppData\Roaming\npm\ng.ps1
①win10系统搜索框输入Windows PowerShell以管理员身份运行
②打开之后输入set-ExecutionPolicy RemoteSigned
③更改权限为A(一定要选择A)
④通过get-ExecutionPolicy 查看当前的状态
⑤最后再次运行项目