复制vue模板的时候,运行npm install失败

npm ERR! code ERESOLVE
npm ERR! ERESOLVE unable to resolve dependency tree
npm ERR! 
npm ERR! Found: html-webpack-plugin@4.0.0-alpha
npm ERR! node_modules/html-webpack-plugin
npm ERR!   dev html-webpack-plugin@"4.0.0-alpha" from the root project   
npm ERR! 
npm ERR! Could not resolve dependency:
npm ERR! dev script-ext-html-webpack-plugin@"2.0.1" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: html-webpack-plugin@3.2.0
npm ERR! node_modules/html-webpack-plugin
npm ERR!   peer html-webpack-plugin@"^3.0.0" from script-ext-html-webpack-plugin@2.0.1
npm ERR!   node_modules/script-ext-html-webpack-plugin
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!
npm ERR! See D:\tool\NodeJs\node_cachel\eresolve-report.txt for a full report.

npm ERR! A complete log of this run can be found in:
npm ERR!     D:\tool\NodeJs\node_cachel\_logs\2022-02-08T00_56_06_480Z-debug.log

在这里插入图片描述
解决方案:安装淘宝镜像:
npm install -g cnpm --registry=http://registry.npm.taobao.org
安装完之后可以通过cnpm -v 检验是否安装成功。如下所示就是安装成功了。
在这里插入图片描述
在运行cnpm install 中,可能会遇到cnpm : 无法加载文件 Run “C:\Windows\system32\cmd.exe /d /s /c node scripts/build.js” ,因为在此系统上禁止运行脚本的错误。
在这里插入图片描述
解决方法:
1、在系统中搜索框 输入 Windos PowerShell
2、点击“管理员身份运行”
3、输入“ set-ExecutionPolicy RemoteSigned”回车
4、根据提示,输入A,回车
5、再次回到cnpm -v执行成功。
ps:不只是cnpm命令,包括pnpm、yarn等这些命令,如果执行时,报这样的错误,都可以通过此方法解决。前提是,如果是用npm命令来安装这些CLI命令工具,必须安装到全局环境中,才能生效。
在这里插入图片描述
再次运行npm install
在这里插入图片描述

文件夹中增加了node_modules文件夹

参考链接:npm install 安装一直失败

可能会有sass-loader和node-sass版本问题,下面重新安装:

cnpm install node-sass@6.0.1
cnpm install sass-loader@7.0.1
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐