From 211b379c070c9497949148895e056b108a1aa8ac Mon Sep 17 00:00:00 2001 From: StyleZhang Date: Thu, 19 Oct 2023 11:32:15 +0800 Subject: [PATCH] fix: npm run start --- web/README.md | 12 ++++-------- web/package.json | 7 ++++--- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/web/README.md b/web/README.md index 1a24a135e795b0..f6d8e6cdb96193 100644 --- a/web/README.md +++ b/web/README.md @@ -64,24 +64,20 @@ Open [http://localhost:3000](http://localhost:3000) with your browser to see the ## Deploy ### Deploy on server First, build the app for production: - ```bash npm run build ``` -Then, move the static files to standalone folder: +Then, start the server: ```bash -mv .next/static .next/standalone/.next -cp -r ./public .next/standalone/.next/ +npm run start ``` -Finally, start the app: +If you want to customize the host and port: ```bash -node .next/standalone/server.js +npm run start --port=3001 --host=0.0.0.0 ``` -If your project needs alternative port or hostname for listening, you can define PORT and HOSTNAME environment variables, before running server.js. For example, `PORT=3000 HOSTNAME=localhost node .next/standalone/server.js`. - ## Lint Code If your IDE is VSCode, rename `web/.vscode/settings.example.json` to `web/.vscode/settings.json` for lint code setting. diff --git a/web/package.json b/web/package.json index 7a225d397f6597..88a0d1dc965410 100644 --- a/web/package.json +++ b/web/package.json @@ -5,7 +5,7 @@ "scripts": { "dev": "next dev", "build": "next build", - "start": "next dev", + "start": "cp -r .next/static .next/standalone/.next/static && cp -r public .next/standalone/public && cross-env PORT=$npm_config_port HOSTNAME=$npm_config_host node .next/standalone/server.js", "lint": "next lint", "fix": "next lint --fix", "eslint-fix": "eslint --fix", @@ -95,6 +95,8 @@ "@types/react-window-infinite-loader": "^1.0.6", "@types/recordrtc": "^5.6.11", "@types/sortablejs": "^1.15.1", + "autoprefixer": "^10.4.14", + "cross-env": "^7.0.3", "eslint": "8.36.0", "eslint-config-next": "^13.4.7", "husky": "^8.0.3", @@ -102,10 +104,9 @@ "miragejs": "^0.1.47", "postcss": "^8.4.21", "sass": "^1.61.0", - "uglify-js": "^3.17.4", "tailwindcss": "^3.3.3", "typescript": "4.9.5", - "autoprefixer": "^10.4.14" + "uglify-js": "^3.17.4" }, "lint-staged": { "**/*.js?(x)": [