vue项目常见运行报错汇总

vue项目运行报错汇总

微信公众号:前端程序猿之路
关注可了解更多的前端知识,反馈问题或建议,请公众号留言。
如果你觉得公众号内容对你有帮助,欢迎关注并转载

1.npm install报错:no such file or directory, open ‘D:\practice\node\package.json’
解决方法:
先执行:npm init -f
然后在安装,安装的时候后面加上–save

npm install --save

如果执行上部操作后还是继续报错,则继续执行

npm init -f

一直这么循环,直到npm run dev可以执行为止
其中
-f表示force的意思,直接-f,npm帮你初始化package.json,并填充各种默认值。
–save 是帮你安装各种依赖
npm run dev 运行项目

2.npm install报错:Missing: chromedriver
提示未安装 chromedriver

npm install chromedriver --chromedriver_cdnurl=http://cdn.npm.taobao.org/dist/chromedriver

3.报错如下:
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).
(1:删除C:\Users\Administrator\下的.npmrc文件。
(2:cmd清理:

npm cache clean --force

执行后会提示: npm WARN using --force I sure hope you know what you are doing
(3:重新执行 npm install

4.安装vue-cli4
执行:npm install -g @vue/cli 或者

yarn global add @vue/cli
vue --version   //查看版本

vue create hello-world //创建一个项目

5.warning react-native > create-react-class > fbjs > core-js@1.2.7: core-js@<2.6.8 is no longer maintained. Please, upgrade to core-js@3 or at least to actual version of core-js@2
更新项目的core-js依赖关系:

npm install --save core-js@^3
6

node不是内部命令
卸载node.js
删除C:\Users\Administrator\AppData\Roaming下边的npm、npm-cache
重新安装node.js,地址:https://nodejs.org/en/download/
安装完成后在dos中输入node -v和npm -v可以看到相应的版本号

7.nodejs npm 卸载
执行

sudo npm uninstall npm -g
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1

或者直接在控制面板中卸载
验证是否卸载成功

node -v  //not found
npm -v //not found

8.node-sass总是下载失败,导致npm run dev失败
解决方法:
(1.在项目目录cmd下运行 npm install -g cnpm --registry=https://registry.npm.taobao.org
(2.下载成功后再运行 cnpm install node-sass
两个都下载成功后重新运行npm run dev就可以正常运行项目了。
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值