在npm install的時候會報錯,經過上網查閱資料之后,解決方法如下:
0、先升級npm版本:npm install -g npm 有可能是npm版本過低報錯
1、然后清理緩存: npm cache clean --force 可能會有之前遺留代碼會產生影響,所以先清理緩存
2、再執行 npm config set registry http://registry.cnpmjs.org
3、再執行 npm install
或者直接執行:
0、先升級npm版本:npm install -g npm 有可能是npm版本過低報錯
1、然后清理緩存: npm cache clean --force 可能會有之前遺留代碼會產生影響,所以先清理緩存
2、直接執行命令:npm install --registry=https://registry.npm.taobao.org --loglevel=silly:
經過以上步驟完美解決了執行npm install報錯的問題;
如果還是報錯,可以多幾次清除緩存npm cache clean --force 我清理了三次之后完美解決了。
還有一個問題就是:
在正確創建vue項目之后 執行 npm run dev時 無法自動打開新建項目的首頁,
解決辦法如下:
找到根目錄下的config文件夾下的index.js文件
'use strict'
// Template version: 1.3.1
// see http://vuejs-templates.github.io/webpack for documentation.
const path = require('path')
module.exports = {
dev: {
// Paths
assetsSubDirectory: 'static',
assetsPublicPath: '/',
proxyTable: {},
// Various Dev Server settings
host: 'localhost', // can be overwritten by process.env.HOST
port: 8080, // can be overwritten by process.env.PORT, if port is in use, a free one will be determined
autoOpenBrowser: false, //是否默認打開瀏覽器,默認是false,改為true即可
errorOverlay: true,
notifyOnErrors: true,
poll: false, // https://webpack.js.org/configuration/dev-server/#devserver-watchoptions-
// Use Eslint Loader?
// If true, your code will be linted during bundling and
// linting errors and warnings will be shown in the console.
useEslint: true,
// If true, eslint errors and warnings will also be shown in the error overlay
// in the browser.
showEslintErrorsInOverlay: false,
/**
* Source Maps
*/
下面是我的公眾號,大家可以關注一下,可以一起學習,一起進步: