Nuxt 3 + Vite: Rollup failed to resolve import “vue-router”

huangapple go评论88阅读模式
英文:

Nuxt 3 + Vite: Rollup failed to resolve import "vue-router"

问题

在我的 Nuxt 3 应用程序构建过程中,出现了以下错误消息:

[vite]: Rollup failed to resolve import "vue-router" from "[...]/node_modules/nuxt/dist/app/components/test-component-wrapper.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external

该应用程序在本地稳定运行。

这个错误是什么意思,我该如何修复它?

期待反馈!

最好的问候,
Tobi

设置:

  • nuxt 3.5.2
  • vite/4.3.1
  • linux-x64 node-v18.14.2
英文:

During the build process of my Nuxt 3 application, the following error message appears:

[vite]: Rollup failed to resolve import "vue-router" from "[...]/node_modules/nuxt/dist/app/components/test-component-wrapper.js".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
build.rollupOptions.external

The application runs stably locally.

What does this error mean and how can I fix it?

I look forward to feedback!

Best regards,
Tobi

Setup:

  • nuxt 3.5.2
  • vite/4.3.1
  • linux-x64 node-v18.14.2

答案1

得分: 3

我通过简单删除node_modulespackage-lock.json来解决了这个问题。

然后npm run build顺利运行了。

显然有些东西被"连线"错了。

最好的祝愿,Tobi

英文:

I solved this by simply deleting node_modules + package-lock.json.

npm run build then ran smoothly.

Apparently something was "wired" wrong.

Best regards, Tobi

huangapple
  • 本文由 发表于 2023年6月14日 23:32:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76475248.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定