简体   繁体   English

npx create-nuxt-app 后跟 npm 运行开发抛出 Vue 包版本不匹配

[英]npx create-nuxt-app followed by npm run dev throws Vue packages version mismatch

I'm just getting started with Nuxt, so I ran npx create-nuxt-app my-app with the following parameters:我刚刚开始使用 Nuxt,所以我使用以下参数运行了npx create-nuxt-app my-app

 Project name: client
 Programming language: JavaScript
 Package manager: Npm
 UI framework: Tailwind CSS
 Nuxt.js modules: Axios - Promise based HTTP client
 Linting tools: ESLint
 Testing framework: AVA
 Rendering mode: Universal (SSR / SSG)
 Deployment target: Server (Node.js hosting)
 Development tools: jsconfig.json (Recommended for VS Code if you're not using typescript)
 Continuous integration: None
 Version control system: None

When I run npm run dev , I get this error:当我运行npm run dev时,我收到此错误:

 ERROR  Failed to compile with 2 errors                                                                                                                 friendly-errors 07:48:10


 ERROR  in ./.nuxt/components/nuxt-error.vue                                                                                                            friendly-errors 07:48:10

Module Error (from ./node_modules/vue-loader/lib/index.js):                                                                                             friendly-errors 07:48:10


Vue packages version mismatch:

- vue@2.6.12
- vue-template-compiler@2.5.22

This may cause things to work incorrectly. Make sure to use the same version for both.
If you are using vue-loader@>=10.0, simply update vue-template-compiler.
If you are using vue-loader@<10.0 or vueify, re-installing vue-loader/vueify should bump vue-template-compiler to the latest.

                                                                                                                                                        friendly-errors 07:48:10
 @ ./.nuxt/index.js 24:0-52 335:0-32
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js
                                                                                                                                                        friendly-errors 07:48:10

 ERROR  in ./.nuxt/components/nuxt-error.vue                                                                                                            friendly-errors 07:48:10

Module build failed (from ./node_modules/vue-loader/lib/index.js):                                                                                      friendly-errors 07:48:10
TypeError: Cannot read property 'parseComponent' of undefined
    at parse (/path/my-app/node_modules/vue-loader/node_modules/@vue/component-compiler-utils/dist/parse.js:15:23)
    at Object.module.exports (/path/my-app/node_modules/vue-loader/lib/index.js:67:22)
                                                                                                                                                        friendly-errors 07:48:10
 @ ./.nuxt/index.js 24:0-52 335:0-32
 @ ./.nuxt/client.js
 @ multi ./node_modules/eventsource-polyfill/dist/browserify-eventsource.js (webpack)-hot-middleware/client.js?reload=true&timeout=30000&ansiColors=&overlayStyles=&path=%2F__webpack_hmr%2Fclient&name=client ./.nuxt/client.js

Here is what I've tried so far:这是我迄今为止尝试过的:

  • npm audit fix --force
  • npm clean cache --force
  • Removing package-lock.json, node_modules and npm install删除 package-lock.json、node_modules 和npm install

EDIT:编辑:

I've managed to fix this by including the following into my package dependencies:我已经设法通过在我的 package 依赖项中包含以下内容来解决此问题:

"vue": "2.5.22",
"vue-server-renderer": "2.5.22",
"vue-template-compiler": "2.5.22"

Now I'm getting a warning though:现在我收到一个警告:

Severity: high
Cross-Site Scripting - https://npmjs.com/advisories/1426
Remote Code Execution - https://npmjs.com/advisories/1548
fix available via `npm audit fix --force`
Will install vue-server-renderer@2.6.12, which is outside the stated dependency range
node_modules/vue-server-renderer/node_modules/serialize-javascript
  vue-server-renderer  2.3.0-beta.1 - 2.6.10
  Depends on vulnerable versions of serialize-javascript
  node_modules/vue-server-renderer

2 vulnerabilities (1 moderate, 1 high)
I can live with this warning, but it looks like the default Nuxt app creation isn't working, at least on my machine.

It works, but it still feels like a workaround of some sort and I'm not sure I'm using the right versions of these packages anyway.它可以工作,但它仍然感觉像是某种解决方法,我不确定我是否使用了这些包的正确版本。

I've also tried upgrading them all up, but that didn't work:我也尝试将它们全部升级,但没有奏效:

Found: vue-template-compiler@2.6.12
npm ERR! node_modules/vue-template-compiler
npm ERR!   vue-template-compiler@"2.6.12" from the root project
npm ERR!   peer vue-template-compiler@"^2.x" from @vue/test-utils@1.1.3
npm ERR!   node_modules/@vue/test-utils
npm ERR!     dev @vue/test-utils@"^1.1.3" from the root project
npm ERR!   3 more (@nuxt/components, @nuxt/vue-app, @nuxt/webpack)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer vue-template-compiler@"2.5.x" from require-extension-hooks-vue@3.0.0
npm ERR! node_modules/require-extension-hooks-vue
npm ERR!   dev require-extension-hooks-vue@"^3.0.0" from the root project
npm ERR!

If anyone has a better suggestion, please let me know!如果有人有更好的建议,请告诉我!

It looks like using yarn instead of NPM fixes this issue.看起来使用 yarn 而不是 NPM 可以解决此问题。 The problem seems to be caused by require-extension-hooks-vue which has a peerDependency on 2.5.22.该问题似乎是由在 2.5.22 上具有 peerDependency 的 require-extension-hooks-vue 引起的。 See this issue for more info.有关更多信息,请参阅此问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 npx create-nuxt-app<project-name> 不工作</project-name> - npx create-nuxt-app <project-name> not working 我可以在没有 npm 启动和 npx create-react-app 的情况下使用 React 运行 index.html 吗? - Can I run index.html with React without npm start and npx create-react-app? 如何从 vue-loader 修复 Vue 包版本不匹配? - How to fix Vue packages version mismatch from vue-loader? Npm run dev 不启动 nuxt 3 本地服务器 - Npm run dev doesnt start up nuxt 3 local server 如何从.vue文件创建NPM包 - How to Create NPM packages from a .vue file 在 Vue.js 应用程序中包含 npm 包 - Including npm packages in Vue.js app npm 和 npx create-react-app 安装的区别 - Difference between npm and npx create-react-app installation 如何在不使用 npm run dev 重新启动服务器的情况下编辑 vue.js 应用程序 - How can I edit a vue.js app without restart the server with npm run dev 错误:在 npx create-react-app 运行期间产生 UNKNOWN - Error: spawn UNKNOWN during npx create-react-app run 我正在使用“npx create-react-app”创建一个新的 reactjs 应用程序,当它完成并尝试使用“npm start”运行它时,我收到一个错误 - I'am creating a new reactjs application using “ npx create-react-app” , and when it's done and trying to run it using “npm start” , I get an error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM