1. 程式人生 > >mac下使用vue create 專案名稱 建立專案後無法執行ERROR  Error: Cannot find module 'vue-template-compiler/package.json'

mac下使用vue create 專案名稱 建立專案後無法執行ERROR  Error: Cannot find module 'vue-template-compiler/package.json'

mac下使用vue create 專案名稱 建立專案後無法執行啟動問題

promote:vue_pro wangxinqiang$ npm run serve

> [email protected] serve /Users/wangxinqiang/Desktop/@vue:cli3/vue_pro
> vue-cli-service serve

 INFO  Starting development server...
 ERROR  Error: Cannot find module 'vue-template-compiler/package.json'
Error: Cannot find module 'vue-template-compiler/package.json'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:603:15)
    at Function.Module._load (internal/modules/cjs/loader.js:529:25)
    at Module.require (internal/modules/cjs/loader.js:658:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at api.chainWebpack.webpackConfig (/usr/local/lib/node_modules/@vue/cli-service/lib/config/base.js:73:32)
    at webpackChainFns.forEach.fn (/usr/local/lib/node_modules/@vue/cli-service/lib/Service.js:227:40)
    at Array.forEach (<anonymous>)
    at Service.resolveChainableWebpackConfig (/usr/local/lib/node_modules/@vue/cli-service/lib/Service.js:227:26)
    at Service.resolveWebpackConfig (/usr/local/lib/node_modules/@vue/cli-service/lib/Service.js:231:48)
    at PluginAPI.resolveWebpackConfig (/usr/local/lib/node_modules/@vue/cli-service/lib/PluginAPI.js:138:25)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/wangxinqiang/.npm/_logs/2019-07-14T01_59_08_811Z-debug.log

解決方法:
1.更新最新npm
npm install npm -g
2.解除安裝之前vue-cli版本(如果是2.x版本)
npm uninstall -g vue-cli
3.安裝新版本(3.x版本)
npm install -g @vue/cli

ok,此