Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vue-template-compiler/package.json missing module with every new project

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 :/

like image 601
Buckethead Avatar asked Jun 11 '26 07:06

Buckethead


1 Answers

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"
like image 51
Pankaj Rupapara Avatar answered Jun 13 '26 21:06

Pankaj Rupapara



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!