gpt4 book ai didi

node.js - vue-template-compiler/package.json 每个新项目都缺少模块

转载 作者:行者123 更新时间:2023-12-05 02:14:21 25 4
gpt4 key购买 nike

目前,我从linux切换到windows,开始搭建编程环境。我不记得在 linux 上有过类似的问题,但重点是:1. 安装 Node.js2. npm install -g @vue/cli 用于 CLI 安装3. vue create my-app4. npm run serve给予:

    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,开始构建然后:

 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 成功了:

 DONE  Compiled successfully in 2536ms  

我用 vue crate my-app-name 创建的每个项目都必须手动安装 vue-template-compiler ,但后来我尝试使用 create vue init webpack-simple my-next-app 一切都毫无问题地构建并运行。使用 create 创建新的 vue 项目有什么区别 - 创建一个由 vue-cli-service 支持的新项目init - 从远程模板生成项目(旧版 API,需要 @vue/cli-init)

附言。是的,我尝试在全局安装 vue-template-compiler。

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?那是我安装的第一件事:/

最佳答案

最近我遇到了同样的问题,我确实使用更新的几个包修复了我当前版本的问题,如下所示。

  1. "vue":"2.5.17"
  2. "vue-template-compiler": "2.5.17"

关于node.js - vue-template-compiler/package.json 每个新项目都缺少模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53712893/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com