简体   繁体   English

使用“nuxi”CLI 的 Nuxt 生成命令在 Netlify 上失败,但在本地没有

[英]Nuxt generate command with "nuxi" CLI fails on Netlify but not locally

This is a new Nuxt2 project with target: static (SSG) upgraded to Nuxt Bridge in order to use Vue3 syntax, Vite and most of the Nuxt3 features.这是一个新的 Nuxt2 项目, target: static (SSG)升级到 Nuxt Bridge 以使用 Vue3 语法、Vite 和大部分 Nuxt3 功能。

I run the build command npm run generate successfully on my own system with Node 14.17.3.我使用 Node 14.17.3 在我自己的系统上成功运行构建命令npm run generate This script triggers "nuxi generate" (nuxi is the Nuxt3 CLI).此脚本触发“nuxi generate”(nuxi 是 Nuxt3 CLI)。

On Netlify the generate script seems to fail because it cannot find Nuxi (?).在 Netlify 上,生成脚本似乎失败了,因为它找不到 Nuxi (?)。

Here is the contents of package.json:这是 package.json 的内容:

  "scripts": {
    "dev": "nuxi dev",
    "build": "nuxi build",
    "start": "node .output/server/index.mjs",
    "generate": "nuxi generate"
  },
  "dependencies": {
    "@nuxt/kit": "npm:@nuxt/kit-edge@^3.0.0-27277498.850ef69",
    "@nuxtjs/i18n": "^7.2.0",
    "core-js": "^3.15.1",
    "nuxt-edge": "latest"
  },
  "devDependencies": {
    "@intlify/vue-i18n-loader": "^1.1.0",
    "@nuxt/bridge": "npm:@nuxt/bridge-edge@^3.0.0-27277498.850ef69",
    "hgrid-css": "^0.7.1-beta",
    "sass": "^1.43.4",
    "sass-loader": "^10.1.1"
  }

Netlify error output: Netlify 错误输出:


3:09:23 PM: $ npm run generate
3:09:23 PM: > my-project-name@1.0.0 generate
3:09:23 PM: > nuxi generate
3:09:23 PM: [log] Nuxt CLI v3.0.0-27277498.850ef69
3:09:27 PM: [error] ENOENT: no such file or directory, open '/opt/build/repo/.nuxt/tsconfig.json'
3:09:27 PM: ​
3:09:27 PM: ────────────────────────────────────────────────────────────────
3:09:27 PM:   "build.command" failed                                        
3:09:27 PM: ────────────────────────────────────────────────────────────────
3:09:27 PM: ​
3:09:27 PM:   Error message
3:09:27 PM:   Command failed with exit code 1: npm run generate

Not sure what the tsconfig.json is doing in the error message, I use plain JS and have no such file.不确定错误消息中的 tsconfig.json 正在做什么,我使用纯 JS 并且没有这样的文件。

What do I have to include in order to get Netlify to use or find the Nuxi CLI correctly?为了让 Netlify 正确使用或找到 Nuxi CLI,我必须包含哪些内容?

Other tips?其他提示? Thanks!谢谢!

With me it also did not work with nuxi generate with bridge: false in nuxt.config.js .对我来说,它也不适用于nuxi generate with bridge: false in nuxt.config.js But after commenting it out it worked fine.但是在评论它之后它工作得很好。 (Documented here: https://v3.nuxtjs.org/getting-started/bridge/#ensure-everything-goes-well ) (此处记录: https : //v3.nuxtjs.org/getting-started/bridge/#ensure-everything-goes-well

But with bridge enabled i get this error when running nuxi dev :但是启用网桥后,我在运行nuxi dev时收到此错误:

WARN  [worker] Invalid or unexpected token  

  at Loader.moduleStrategy (internal/modules/esm/translators.js:145:18)
  at async link (internal/modules/esm/module_job.js:63:21)

Maybe you also have bridge: false in your nuxt.config.js .也许你的nuxt.config.js也有bridge: false

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM