[React, scaffolding and yarn] Expose webpack rules and report an error: error Couldn't find a package.json file in “/Users/zengguili/textapp”

question

Enter the command: yarn eject
Error:


cengguilideMacBook-Pro:textApp zengguili$ yarn eject
yarn run v1.22.19
error Couldn't find a package.json file in "/Users/zengguili/textapp"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Enter the command: yarn build
Error:

cengguilideMacBook-Pro:textApp zengguili$ yarn build
yarn run v1.22.19
error Couldn't find a package.json file in "/Users/zengguili/textapp"
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Cause of error: The dependency package has generated a cache, (that is, the npm i package has been downloaded repeatedly)

solution

Option One

  1. yarn buildThis is to solve the problem that the project already has a package.json file, but running the command: still reports an error "error Couldn't find a package.json file in "/Users/zengguili/textapp".

package.json file:

insert image description here

  1. Reason: It is because the command execution does not enter the file item to be executed.

implement:

cd myapp
yarn build

After execution, the following code will appear:

cengguilideMacBook-Pro:textApp zengguili$ cd myapp
cengguilideMacBook-Pro:myapp zengguili$ yarn build
yarn run v1.22.19
$ react-scripts build
Creating an optimized production build...
Compiled successfully.

File sizes after gzip:

  45.43 kB  build/static/js/main.4fddd451.js

The project was built assuming it is hosted at /.
You can control this with the homepage field in your package.json.

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:

  https://cra.link/deployment

✨  Done in 14.08s.

The same goes for the others.

Option II

Solve the problem that there is no package.json file.

  1. Excuting an order:yarn init
cengguilideMacBook-Pro:textApp zengguili$ yarn init
yarn init v1.22.19
question name (textapp): textapp
question version (1.0.0): 1.0.0
question description: 
question entry point (index.js): index.js
question repository url: 
question author: zengguili
question license (MIT): 
question private: 
success Saved package.json
✨  Done in 50.26s.
  1. Click on package.json to see that it has been created.
    Information in the package.json file
  2. error Couldn't find a package.json file has disappeared

Guess you like

Origin blog.csdn.net/qiqizgl777/article/details/129498971