0

Creating a new project with "create-react-app" gives this kind of a folder structure:

├── README.md
├── node_modules
├── package.json
├── .gitignore
├── build
├── public
│   ├── favicon.ico
│   ├── index.html
│   └── manifest.json
└── src
    ├── App.css
    ├── App.js
    ├── App.test.js
    ├── index.css
    ├── index.js
    ├── logo.svg
    └── serviceWorker.js

However, I have a project which does not use "public" and "src" but "client" and "server" instead. Furthermore, it does not have an index.js etc. When I do the "npm run dev" everything works fine on a localhost:3000. However, I cannot do a "npm run build". The error that I get is:

Could not find a required file.
  Name: index.html
  Searched in: /HOMEFOLDER/PROJECT/public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! PROJECTNAME@1.0.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the PROJECTNAME@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

The error log is:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using npm@6.12.0
3 info using node@v12.13.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle PROJECTNAME@1.0.0~prebuild: PROJECTNAME@1.0.0
6 info lifecycle PROJECTNAME@1.0.0~build: PROJECTNAME@1.0.0
7 verbose lifecycle PROJECTNAME@1.0.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle PROJECTNAME@1.0.0~build: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/HOME/PROJECTFOLDER/node_modules/.bin:/home/username/.nix-profile/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle PROJECTNAME@1.0.0~build: CWD: /HOME/PROJECTFOLDER
10 silly lifecycle PROJECTNAME@1.0.0~build: Args: [ '-c', 'react-scripts build' ]
11 silly lifecycle PROJECTNAME@1.0.0~build: Returned: code: 1  signal: null
12 info lifecycle PROJECTNAME@1.0.0~build: Failed to exec build script
13 verbose stack Error: PROJECTNAME@1.0.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:210:5)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:210:5)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
14 verbose pkgid PROJECTNAME@1.0.0
15 verbose cwd /HOME/PROJECTFOLDER
16 verbose Linux 5.0.0-36-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
18 verbose node v12.13.0
19 verbose npm  v6.12.0
20 error code ELIFECYCLE
21 error errno 1
22 error PROJECTNAME@1.0.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the PROJECTNAME@1.0.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I have tried adjusting the folders, however it gets simply messed up and is not possible to untangle in a timely manner.

PS Question is in the title.

3xCh1_23
  • 1,491
  • 1
  • 20
  • 39

0 Answers0