3

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! [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! 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. 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. So i run npm install --save vue and then at last npm run serve worked:

 DONE  Compiled successfully in 2536ms  

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)

Ps. Yes i tried install vue-template-compiler 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

Why vue does not see @vue/cli in new project? That was first thing I installed :/

5 Answers 5

2

recently I have faced the same issue, I did fix using an update few packages my current version as per below.

  1. "vue":"2.5.17"
  2. "vue-template-compiler": "2.5.17"
Sign up to request clarification or add additional context in comments.

3 Comments

It's weird, because I installed everything fresh and latest versions. I have not spotted anything useful during looking in GH project's repository.
It's weird, because I installed everything fresh and latest versions. I have not spotted anything useful during looking in GH project's repository. I did upgrade as you wrote, and installed vue-custom-element. But problem still exist. So for now I stand with my solution, I only have 3-4 projects in vue so few commands dont make difference for me now. I will try fix it in free time.
i created new project, and before run in app catalog i typed npm install: npm WARN @vue/[email protected] requires a peer of vue-template-compiler@^2.0.0 but none was installed. up to date in 3.434s So question is why during install vue cli - vue-template-compiler is not installed?
2

As explained here you need to install vue-template-compiler manually, running npm i -g vue-template-compiler fixes the problem.

2 Comments

This is not an acceptable answer if one is not using vue-template-compiler directly in their project.
Tests should run in pipelines as well, installing global libraries is not a good solution.
1

I had to update vue-template-compiler to the exact same version as vue was. In my case both were version 2.6.14

Comments

0

Recently I have faced the same issue, I did a fix using an update few packages my current version as per below.

"vue":"2.5.22" "vue-template-compiler": "2.5.22

I posted also in Vue.js forum https://forum.vuejs.org/t/installation-nightmare/54705

It is very hard for a new user to figure out how and where to do the fixes

What helped me was https://itnext.io/vuejs-and-webpack-4-from-scratch-part-1-94c9c28a534a and https://itnext.io/getting-started-vue-js-and-visual-studio-code-6990f92e918a

Comments

0

I am running Vue 2 and got this error seemingly out of nowhere. The solutions for Vue 3 did not work for me. What worked was rolling back to an old version of package.json. I had run npm fix and updated packages were introduced which caused this error. Reverting those solved the issue.

  1. delete package-lock.json
  2. change package.json to a version that worked
  3. run npm install

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.