Why i get error when build shopify hydrogen app to production mode?

I get this error:

│ Unexpected arguments: --entry, ./server
│ See more help with --help

And this is my package.json file:

{
  "name": "hello-world",
  "private": true,
  "sideEffects": false,
  "version": "0.0.0",
  "scripts": {
    "build": "npm run build:css && shopify hydrogen build --entry ./server",
    "build:css": "postcss styles --base styles --dir app/styles --env production",
    "dev": "npm run build:css && concurrently -g -r npm:dev:css \"shopify hydrogen dev\"",
    "dev:css": "postcss styles --base styles --dir app/styles -w",
    "preview": "npm run build && shopify hydrogen preview",
    "lint": "eslint --no-error-on-unmatched-pattern --ext .js,.ts,.jsx,.tsx .",
    "g": "shopify hydrogen generate"
  },
  "prettier": "@shopify/prettier-config",
  "dependencies": {
    "@remix-run/react": "1.12.0",
    "@shopify/cli": "3.29.0",
    "@shopify/cli-hydrogen": "^4.0.8",
    "@shopify/hydrogen": "^2023.1.5",
    "@shopify/remix-oxygen": "^1.0.3",
    "graphql": "^16.6.0",
    "graphql-tag": "^2.12.6",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "@remix-run/dev": "1.12.0",
    "@shopify/prettier-config": "^1.1.2",
    "autoprefixer": "^10.4.13",
    "concurrently": "^7.6.0",
    "eslint": "^8.20.0",
    "eslint-plugin-hydrogen": "0.12.2",
    "postcss": "^8.4.21",
    "postcss-cli": "^10.1.0",
    "prettier": "^2.8.4",
    "tailwindcss": "^3.2.7"
  },
  "engines": {
    "node": ">=16.13"
  }
}

I have the same issue.

It seems that the new version doesn’t require that argument anymore.

It will automatically look for the file ‘./server.ts’.

You can try deleting that file to see the error “Entry file “./server.ts” not found.”

So the solution is just delete that --entry option

1 Like