简体   繁体   中英

unable to run 'yarn run build'

I'm trying to build my site. It works when I run yarn start

Now I want to build it.

I run yarn run build and i get this error

yarn run build  
yarn run v1.22.17
warning package.json: No license field   
error Command "build" not found.

I have a package.json that contains the same script that allowed previous projects to run.

{
  "name": "bl_site_12_28",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@chakra-ui/icons": "^1.1.1",
    "@chakra-ui/react": "^1.0.0",
    "@emotion/react": "^11.0.0",
    "@emotion/styled": "^11.0.0",
    "@testing-library/jest-dom": "^5.9.0",
    "@testing-library/react": "^10.2.1",
    "@testing-library/user-event": "^12.0.2",
    "chakra-ui-markdown-renderer": "^4.0.0",
    "framer-motion": "^4.0.0",
    "react": "^17.0.2",
    "react-audio-player": "^0.17.0",
    "react-dom": "^17.0.2",
    "react-ga": "^3.3.0",
    "react-icons": "^3.11.0",
    "react-markdown": "^7.1.2",
    "react-player": "^2.9.0",
    "react-router-dom": "^6.2.1",
    "react-scripts": "^3.0.1",
    "web-vitals": "^0.2.2"
  },    "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": [
      "react-app",
      "react-app/jest"
    ]
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

I tried running yarn run as another post suggested to get a list of possible posts, but i get a similar message above. It seems that yarn is not reading my package.json

@KyleRifqi's helpful comment was all that was needed. I used ls to identify the files in the current directly I was running yarn run build from.

I realized the package.json was not in that directory. I cd into the correct directory and then it worked

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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