vue-template-compiler/package.json 缺少每个新项目的模块 [英] vue-template-compiler/package.json missing module with every new project
问题描述
目前从linux切换到windows,开始搭建编程环境.我不记得 linux 上有类似的问题,但重点是:1. 安装 Node.js2. npm install -g @vue/cli
用于 CLI 安装3. vue 创建我的应用
4. npm run serve
给:
Currently, I switched from linux to windows and started to create a programming environment. I don't remember similar problem on linux, but to the point:
1. Installed Node.js
2. npm install -g @vue/cli
for CLI install
3. vue create my-app
4. npm run serve
Gave:
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:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at api.chainWebpack.webpackConfig (D:\vueTest\test\node_modules\@vue\cli-service\lib\config\base.js:73:32)
at webpackChainFns.forEach.fn (D:\vueTest\test\node_modules\@vue\cli-service\lib\Service.js:225:40)
at Array.forEach (<anonymous>)
at Service.resolveChainableWebpackConfig (D:\vueTest\test\node_modules\@vue\cli-service\lib\Service.js:225:26)
at Service.resolveWebpackConfig (D:\vueTest\test\node_modules\@vue\cli-service\lib\Service.js:229:48)
at PluginAPI.resolveWebpackConfig (D:\vueTest\test\node_modules\@vue\cli-service\lib\PluginAPI.js:115:25)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test@0.1.0 serve: vue-cli-service serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test@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! C:\Users\Michal\AppData\Roaming\npm-cache_logs\2018-12-09T203013_264Z-debug.log`
5. vue-cli-service inspect --mode production
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:580:15)
at Function.Module.load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at api.chainWebpack.webpackConfig (D:\vueTest\test\nodemodules\@vue\cli-service\lib\config\base.js:73:32)
at webpackChainFns.forEach.fn (D:\vueTest\test\nodemodules\@vue\cli-service\lib\Service.js:225:40)
at Array.forEach (<anonymous>)
at Service.resolveChainableWebpackConfig (D:\vueTest\test\nodemodules\@vue\cli-service\lib\Service.js:225:26)
at Service.resolveWebpackConfig (D:\vueTest\test\nodemodules\@vue\cli-service\lib\Service.js:229:48)
at PluginAPI.resolveWebpackConfig (D:\vueTest\test\node_modules\@vue\cli-service\lib\PluginAPI.js:115:25)`
6. 我尝试过 vue ui
但同样的故事,所以我为创建的应用程序安装了缺少的模块:npm install vue-template-compiler
,顺利,包裹添加.7. vue run serve
,开始构建,然后:
6. I tried through vue ui
but same story, so I installed missing module for created app: npm install vue-template-compiler
, went smooth, package added.
7. vue run serve
, starting building and then:
ERROR Failed to compile with 3 errors
This dependency was not found:
* vue in ./src/main.js, ./src/App.vue and 1 other
To install it, you can run: npm install --save vue
8. 所以我运行 npm install --save vue
然后最后 npm run serve
工作:
8. So i run npm install --save vue
and then at last npm run serve
worked:
DONE Compiled successfully in 2536ms
我使用 vue crate my-app-name
创建的每个项目都必须手动安装 vue-template-compiler
,但后来我尝试使用 create vue init webpack-simple my-next-app
一切都建立起来没有问题并运行.使用 create 创建新项目有什么区别 - 创建由 vue-cli-service
和 init 提供支持的新项目 - 从远程模板生成项目(旧 API,需要 @vue/cli-init)
Every single project I created with vue crate my-app-name
must have had vue-template-compiler
installed manually, but then I tried with create vue init webpack-simple my-next-app
everything build up without problems and run.
What is difference with creating new vue project with create - create a new project powered by vue-cli-service
and init - generate a project from a remote template (legacy API, requires @vue/cli-init)
附言.是的,我尝试全局安装 vue-template-compile
r.
Ps. Yes i tried install vue-template-compile
r globally.
Environment Info:
System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz
Binaries:
Node: Not Found
Yarn: Not Found
npm: 5.0.4 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 42.17134.1.0
npmPackages:
@vue/babel-preset-app: 3.2.0
@vue/cli-overlay: 3.2.0
@vue/cli-plugin-babel: ^3.2.0 => 3.2.0
@vue/cli-plugin-eslint: ^3.2.0 => 3.2.1
@vue/cli-service: ^3.2.0 => 3.2.0
@vue/cli-shared-utils: 3.2.0
@vue/component-compiler-utils: 2.3.0
@vue/preload-webpack-plugin: 1.1.0
@vue/web-component-wrapper: 1.2.0
babel-helper-vue-jsx-merge-props: 2.0.3
babel-plugin-transform-vue-jsx: 4.0.1
eslint-plugin-vue: ^5.0.0-0 => 4.7.1
vue-eslint-parser: 2.0.3
vue-hot-reload-api: 2.3.1
vue-loader: 15.4.2
vue-style-loader: 4.1.2
vue-template-es2015-compiler: 1.6.0
npmGlobalPackages:
@vue/cli: Not Found
为什么 vue 在新项目中看不到@vue/cli?那是我安装的第一件事:/
Why vue does not see @vue/cli in new project? That was first thing I installed :/
推荐答案
如解释 此处 需要手动安装vue-template-compiler
,运行npm i -g vue-template-compiler
即可解决问题.
As explained here you need to install vue-template-compiler
manually, running npm i -g vue-template-compiler
fixes the problem.
这篇关于vue-template-compiler/package.json 缺少每个新项目的模块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!