当前位置: 代码网 > it编程>前端脚本>Vue.js > 解决vue项目Error:Cannot find module‘xxx’类报错问题

解决vue项目Error:Cannot find module‘xxx’类报错问题

2024年10月27日 Vue.js 我要评论
vue项目error:cannot find module‘xxx’类报错现发现只要是报错 error: cannot find module ‘xxx&rsquo

vue项目error:cannot find module‘xxx’类报错

现发现只要是报错 error: cannot find module ‘xxx’(例如 error: cannot find module ‘webpack’)这类的问题都可以用下面的方法解决。

报错内容如下

运行 npm install 没问题,运行 npm run serve 就会报错:

error: cannot find module ‘webpack’

解决方案

  • 到项目文件夹下,删除 node_modules 文件和 package-lock.json 文件。注意不是package.json(如果删不掉,看下项目是不是打开了,关了再试试)
  • 在项目下运行npm install
  • 继续运行npm run dev(这里不一定是dev,要根据自己实际项目中的配置来,就是启动项目就行)

后面如果报需要安装什么插件,再继续安装插件,重启即可。

一定要删除 package-lock.json 不然没有效果!!

安装依赖时错误:fatal: repository ‘https://github.com/nhn/raphael.git/’ not found

vue项目 npm i 安装依赖失败

npm err! error while executing:
npm err! d:\git\cmd\git.exe ls-remote -h -t https://github.com/nhn/raphael.git
npm err! fatal: unable to access 'https://github.com/nhn/raphael.git/': openssl ssl_read: connection was reset, errno 10054
npm err!
npm err! exited with error code: 128

npm err! a complete log of this run can be found in:
npm err!     c:\users\glq\appdata\roaming\npm-cache\_logs\2021-08-05t01_57_51_837z-debug.log

解决方案 1:

当前网络无法访问 github.com ,建议切换为手机热点网络。

解决方案 2:

  • 1、配置淘宝镜像
npm install --registry=https://registry.npm.taobao.org //单次使用
npm config set registry https://registry.npm.taobao.org //永远使用

配置完成后检验是否成功:

npm config get registry //或者下一行
npm info express//或者上一行
  • 2、再次安装
npm i

注意:

如果想还原 npm 仓库地址,只需再把地址配置成 npm 镜像就可以了

npm config set registry https://registry.npmjs.org/

总结

以上为个人经验,希望能给大家一个参考,也希望大家多多支持代码网。

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com