如何使用入门模板修复新创建的 nuxt.js 应用程序的相关模块错误?
How to fix relative module error for a newly created nuxt.js app with starter template?
我尝试使用官方网站的指南创建一个 nuxt 应用程序,选择默认选项是因为我想要入门模板但是在 运行 npm run dev
上,我一直遇到错误:
This relative module was not found:
* ./components/nuxt-error.vue in ./.nuxt/index.js
我已经尝试搜索它,但找不到任何有用的东西 resource/fix。我也尝试了 vue init nuxt-community/starter-template
安装,但我仍然遇到同样的错误。
有任何修复吗?
这 Error
基本上意味着,在您的一个文件中,您试图导入另一个具有 ./components/nuxt-error.vue
相对路径的文件,但不存在具有此路径的文件。
不过
我刚读到 vue init nuxt-community/starter-template
已弃用,不再维护。您应该使用 npx create-nuxt-app <yourAppName>
重新启动您的项目,而不是修复此 Error
。 https://github.com/nuxt-community/starter-template
所以我找到了解决办法。我无法找出错误,因为 nuxt-error.vue 文件实际上已正确导入。结果是“npm”安装一直给我带来问题(TailwindCSS 也有问题)。
因此,如果您在加载基础 nuxt 应用程序时遇到此错误,请改用“yarn”重新创建项目。像魔术一样工作!
我尝试使用官方网站的指南创建一个 nuxt 应用程序,选择默认选项是因为我想要入门模板但是在 运行 npm run dev
上,我一直遇到错误:
This relative module was not found:
* ./components/nuxt-error.vue in ./.nuxt/index.js
我已经尝试搜索它,但找不到任何有用的东西 resource/fix。我也尝试了 vue init nuxt-community/starter-template
安装,但我仍然遇到同样的错误。
有任何修复吗?
这 Error
基本上意味着,在您的一个文件中,您试图导入另一个具有 ./components/nuxt-error.vue
相对路径的文件,但不存在具有此路径的文件。
不过
我刚读到 vue init nuxt-community/starter-template
已弃用,不再维护。您应该使用 npx create-nuxt-app <yourAppName>
重新启动您的项目,而不是修复此 Error
。 https://github.com/nuxt-community/starter-template
所以我找到了解决办法。我无法找出错误,因为 nuxt-error.vue 文件实际上已正确导入。结果是“npm”安装一直给我带来问题(TailwindCSS 也有问题)。
因此,如果您在加载基础 nuxt 应用程序时遇到此错误,请改用“yarn”重新创建项目。像魔术一样工作!