将 nextjs 应用程序部署到 Google 应用程序引擎时,选项名称无效(“--modules-folder=/layers/google.nodejs.yarn/yarn_modules/node_modules”)

问题描述 投票:0回答:1

我按照以下步骤操作:

  • distDir: 'build'
    next.config.js

  • 已修改

    package.json

    {
      "name": "SHOP",
      "version": "1.0.8",
      "description": "Next.js high-performance e-commerce websites.",
      "keywords": [
        "boundless",
        "boundless-commerce",
        "cms",
        "headless",
        "ecommerce",
        "api",
        "checkout",
        "typescript",
        "cms",
        "cart",
        "nextjs",
        "theme"
      ],
      "main": "index.js",
      "repository": "https://github.com/namcao502/SHOP",
      "author": "Nam <[email protected]>",
      "license": "MIT",
    **  "scripts": {
        "analyze": "cross-env ANALYZE=true next build",
        "dev": "next dev",
        "build": "next build",
        "start": "next start",
        "gcp-build": "",
        "deploy": "gcloud config set project winter-monolith-405012 && gcloud app deploy app.yaml --version=0-1-2 --quiet",
        "lint": "npx eslint --ext .ts --ext .tsx . && npx stylelint ./styles"
      },**
      "dependencies": {
        "@fontsource/roboto": "^4.5.3",
        "@fortawesome/fontawesome-free": "^5.15.4",
        "@fortawesome/fontawesome-svg-core": "^1.2.36",
        "@fortawesome/free-brands-svg-icons": "^5.15.4",
        "@fortawesome/free-solid-svg-icons": "^5.15.4",
        "@fortawesome/react-fontawesome": "^0.1.16",
        "@popperjs/core": "^2.11.2",
        "@reduxjs/toolkit": "^1.7.1",
        "@types/js-cookie": "^3.0.1",
        "@types/lodash": "^4.14.178",
        "@types/nprogress": "^0.2.0",
        "@types/react-redux": "^7.1.25",
        "@types/react-transition-group": "^4.4.6",
        "@use-gesture/vanilla": "^10.2.5",
        "animate.css": "^4.1.1",
        "body-scroll-lock": "^4.0.0-beta.0",
        "bootstrap": "^5.1.3",
        "boundless-api-client": "^0.1.4",
        "boundless-checkout-react": "^1.1.5",
        "clsx": "^1.1.1",
        "currency.js": "^2.0.4",
        "js-cookie": "^3.0.1",
        "lodash": "^4.17.21",
        "next": "^13.4.19",
        "nprogress": "^0.2.0",
        "photoswipe": "^5.3.8",
        "prop-types": "^15.8.1",
        "qs": "^6.10.2",
        "rc-slider": "^9.7.5",
        "react": "^18.2.0",
        "react-bootstrap": "^2.8.0",
        "react-content-loader": "^6.1.0",
        "react-dom": "^18.2.0",
        "react-photoswipe-gallery": "^2.2.7",
        "react-redux": "^8.1.2",
        "react-transition-group": "^4.4.5",
        "sass": "^1.45.0",
        "sharp": "^0.32.5",
        "swiper": "8",
        "typescript": "^4.5.4",
        "xmlbuilder": "^15.1.1",
        "yarn": "^1.22.21"
      },
      "devDependencies": {
        "@next/bundle-analyzer": "^12.3.4",
        "@types/body-scroll-lock": "^3.1.0",
        "@types/lodash": "^4.14.178",
        "@types/node": "^17.0.0",
        "@types/qs": "^6.9.7",
        "@types/react": "^18.2.20",
        "@types/react-dom": "^18.2.7",
        "@typescript-eslint/eslint-plugin": "^5.9.1",
        "@typescript-eslint/parser": "^5.9.1",
        "cross-env": "^7.0.3",
        "eslint": "^8.6.0",
        "eslint-config-next": "^12.0.7",
        "postcss": "^8.4.28",
        "stylelint": "^14.2.0",
        "stylelint-config-sass-guidelines": "^9.0.1",
        "stylelint-config-standard": "^24.0.0",
        "ts-node": "^10.4.0"
      },
      "engines": {
        "node": ">=16.8",
        "yarn": ">=1.x"
      }
    }
    
  • app.yaml

    runtime: nodejs
    env: flex
    runtime_config:
        operating_system: "ubuntu22"
    automatic_scaling:
        min_num_instances: 1
        max_num_instances: 10
        cool_down_period_sec: 180
        cpu_utilization:
            target_utilization: 0.9
    resources:
        cpu: 2
        memory_gb: 4.6
        disk_size_gb: 10
    network:
        name: default
    
  • npm run build

  • npm run deploy

我收到了这个错误:

Build failed: Unknown Syntax Error: Invalid option name ("--modules-folder=/layers/google.nodejs.yarn/yarn_modules/node_modules").

$ yarn install [--json] [--immutable] [--immutable-cache] [--refresh-lockfile] [--check-cache] [--check-resolutions] [--inline-builds] [--mode #0]; Error ID: 12c8ef4a

我尝试了 Google App Engine 和 Firebase 托管,错误仍然相同。请帮我部署它。顺便说一句,Vercel 很好,但我想将它托管在 Google App Engine 上。

javascript google-app-engine yarnpkg next.js13
1个回答
0
投票

我通过从

yarn
中的
engines
属性中删除
package.json
解决了这个问题。我仍然使用
yarn
,只是将其从
package.json
engines
属性中删除。

所以,这是我的

firebase
设置,效果很好。

package.json:

{
  "main": "src/firebaseApp.js",
  "engines": {
    "node": "18",
    - "yarn": "1" // Deleted this line
  },
  "dependencies": {
    "firebase-admin": "^12.0.0",
    "firebase-functions": "^4.6.0",
  },
  "scripts": {
    "deploy:api": "firebase deploy --only functions"
  }
}

firebase.json:

{
  "functions": [
    {
      "source": ".",
      "codebase": "default",
      "ignore": [".git", "firebase-debug.log", "firebase-debug.*.log"]
    }
  ]
}
© www.soinside.com 2019 - 2024. All rights reserved.