mac下使用vue create 项目名称 创建项目后无法运行ERROR  Error: Cannot find module 'vue-template-compiler/package.json'

mac下使用vue create 项目名称 创建项目后无法运行启动问题

promote:vue_pro wangxinqiang$ npm run serve

> vue_pro@0.1.0 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! vue_pro@0.1.0 serve: `vue-cli-service serve` npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the vue_pro@0.1.0 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

解决方法二:

由于我使用的文件夹名字“@vue/cli”导致mac上新建项目无法运行,因此换一个普通名字即可

因为这个名字在vscode上被格式化成,导致无法读取

ok,此刻问题处理完毕

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

扫码关注云+社区

领取腾讯云代金券