2

I cloned a react project, which was probably developed under pure Windows, into WSL of my windows.

It seems that, to launch a react app properly in IE and Edge, we need to build the project and serve it. So I did yarn add react-scripts, yarn install and yarn build, which gave me:

The build folder is ready to be deployed.
You may serve it with a static server:

  yarn global add serve
  serve -s build

Find out more about deployment here:

  bit.ly/CRA-deploy

Then,

$ yarn global add serve
yarn global v1.22.0
[1/4] Resolving packages...
[2/4] Fetching packages...
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Installed "serve@11.3.0" with binaries:
      - serve
Done in 1.49s.

$ serve -s build
No command 'serve' found, did you mean:
 Command 'pserve' from package 'python-pyramid' (universe)
 Command 'server' from package 'rsplib-legacy-wrappers' (universe)
serve: command not found

Here is package.json. Does anyone know what's the problem?

{
  "name": "frontend",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@material-ui/core": "^4.9.8",
    "@microsoft/office-js-helpers": "^1.0.2",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "@types/react-stripe-elements": "^6.0.4",
    "@uifabric/react-cards": "^0.109.49",
    "axios": "^0.19.2",
    "color": "^3.1.2",
    "cross-storage": "^1.0.0",
    "dva": "^2.4.1",
    "dva-model-creator": "^0.4.3",
    "formik": "^2.1.4",
    "lodash": "^4.17.15",
    "moment": "^2.24.0",
    "monaco-editor": "^0.20.0",
    "node-sass": "^4.13.1",
    "office-ui-fabric-react": "^7.105.4",
    "query-string": "^6.11.1",
    "react": "^16.13.1",
    "react-app-polyfill": "^1.0.6",
    "react-dom": "^16.13.1",
    "react-monaco-editor": "^0.35.0",
    "react-scripts": "^3.4.1",
    "react-stripe-elements": "^6.1.1",
    "redux-devtools-extension": "^2.13.8",
    "styled-components": "^5.0.1",
    "typescript": "^3.8.3",
    "yup": "^0.28.3"
  },
  "scripts": {
    "start": "SET PORT=8000 && react-scripts start",
    "build": "react-scripts --max_old_space_size=8096 build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "@types/color": "^3.0.1",
    "@types/cross-storage": "^0.8.29",
    "@types/jest": "^25.1.4",
    "@types/lodash": "^4.14.149",
    "@types/node": "^13.9.5",
    "@types/query-string": "^6.3.0",
    "@types/react": "^16.9.27",
    "@types/react-dom": "^16.9.5",
    "@types/react-redux": "^7.1.7",
    "@types/styled-components": "^5.0.1",
    "@types/yup": "^0.26.33"
  }
}
RobC
  • 22,977
  • 20
  • 73
  • 80
SoftTimur
  • 5,630
  • 38
  • 140
  • 292
  • It looks like you just want to serve your application? Have you tried “yarn start”? – EvanM Apr 08 '20 at 11:40
  • When we use `yarn start`, the app does not work well in IE or Edge. Previously, the developer of the project told me that we need to build it and serve it, because it is react... – SoftTimur Apr 08 '20 at 12:12
  • 1
    So if you’re just looking for the location of something added by yarn global, see https://dev.to/c33s/yarn-global-package-install-location-16p4 – EvanM Apr 08 '20 at 12:18
  • 1
    You can see that https://stackoverflow.com/a/40333409/5594492 the `package.json` have no relation with the issue, it's beaucoup your terminal can't find the binary folder from yarn – Safi Nettah Apr 08 '20 at 12:27
  • that's the wrong yarn tag. I'd edit it, but SO says that the question is mostly code. I didn't make any changes to the body of the question, mind you. – CoryCoolguy Apr 11 '20 at 16:28

2 Answers2

1

in package.json u can add some step like

 "scripts": {
...
    "start:prod": "serve -s dist -l 3000"
...
  }

after that run locally

npm run-script start:prod
Jakub Kurdziel
  • 3,216
  • 2
  • 12
  • 22
0

you need to add serve globally with compatible version with node version.

Amit Kumar
  • 101
  • 7