I have a node.js app that is working fine when I run it with npm start but when I try to build it the process freezes. This is what I see:
$ npm run build
> reactsearch@0.1.0 build /home/ppdevts4/public_html/reactsearch
> react-scripts build
Creating an optimized production build...
I can leave it for 2 hours or 2 days and it never changes. On the server I can see that the CPU peaks at about 30%, RAM at about 10% and Input/Output usage at about 50%. So it does not seem like resources are a problem.
I found a file called error_log in public_html and no new entries have been added to it after I ran npm run build.
Any suggests how to debug this please? I'm new to node.js.
Thanks, Phil
Updated ...
After removing server limits the script now ends with an error. This is what I see in the debug.log in .npm/_logs folder:
0 info it worked if it ends with ok
1 verbose cli [ '/home/ppdevts4/bin/node', '/home/ppdevts4/bin/npm', 'run', 'build' ]
2 info using npm@6.12.0
3 info using node@v12.9.1
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle reactsearch@0.1.0~prebuild: reactsearch@0.1.0
6 info lifecycle reactsearch@0.1.0~build: reactsearch@0.1.0
7 verbose lifecycle reactsearch@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle reactsearch@0.1.0~build: PATH: /home/ppdevts4/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ppdevts4/public_html/reactsearch/node_modules/.bin:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/cpanel/3rdparty/lib/path-bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/opt/cpanel/composer/bin:/home/ppdevts4/.local/bin:/home/ppdevts4/bin
9 verbose lifecycle reactsearch@0.1.0~build: CWD: /home/ppdevts4/public_html/reactsearch
10 silly lifecycle reactsearch@0.1.0~build: Args: [ '-c', 'react-scripts build' ]
11 silly lifecycle reactsearch@0.1.0~build: Returned: code: 1 signal: null
12 info lifecycle reactsearch@0.1.0~build: Failed to exec build script
13 verbose stack Error: reactsearch@0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/home/ppdevts4/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:209:13)
13 verbose stack at ChildProcess.<anonymous> (/home/ppdevts4/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:209:13)
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 reactsearch@0.1.0
15 verbose cwd /home/ppdevts4/public_html/reactsearch
16 verbose Linux 3.10.0-962.3.2.lve1.5.25.10.el7.x86_64
17 verbose argv "/home/ppdevts4/bin/node" "/home/ppdevts4/bin/npm" "run" "build"
18 verbose node v12.9.1
19 verbose npm v6.12.0
20 error code ELIFECYCLE
21 error errno 1
22 error reactsearch@0.1.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the reactsearch@0.1.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 ]
Another post said npm install react-scripts --save might fix it but the error log is the same afterwards.
Any suggestions how to fix this error?
Updated 14 Oct 2019
I created a t3.s instance on AWS with 8 CPUs and 32GB RAM and it gave a similar error so it does not seem like this is caused by lack of memory.
Here is the log:
0 info it worked if it ends with ok
1 verbose cli [ '/home/ec2-user/bin/node', '/home/ec2-user/bin/npm', 'run', 'build' ]
2 info using npm@6.10.2
3 info using node@v12.9.1
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle reactsearch@0.1.0~prebuild: reactsearch@0.1.0
6 info lifecycle reactsearch@0.1.0~build: reactsearch@0.1.0
7 verbose lifecycle reactsearch@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle reactsearch@0.1.0~build: PATH: /home/ec2-user/nodejs/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/ec2-user/public_html/reactsearch/node_modules/.bin:/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/opt/aws/bin:/home/ec2-user/.local/bin:/home/ec2-user/bin
9 verbose lifecycle reactsearch@0.1.0~build: CWD: /home/ec2-user/public_html/reactsearch
10 silly lifecycle reactsearch@0.1.0~build: Args: [ '-c', 'react-scripts build' ]
11 silly lifecycle reactsearch@0.1.0~build: Returned: code: 1 signal: null
12 info lifecycle reactsearch@0.1.0~build: Failed to exec build script
13 verbose stack Error: reactsearch@0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (/home/ec2-user/nodejs/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:326:16)
13 verbose stack at EventEmitter.emit (events.js:209:13)
13 verbose stack at ChildProcess.<anonymous> (/home/ec2-user/nodejs/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:209:13)
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 reactsearch@0.1.0
15 verbose cwd /home/ec2-user/public_html/reactsearch
16 verbose Linux 4.14.146-93.123.amzn1.x86_64
17 verbose argv "/home/ec2-user/bin/node" "/home/ec2-user/bin/npm" "run" "build"
18 verbose node v12.9.1
19 verbose npm v6.10.2
20 error code ELIFECYCLE
21 error errno 1
22 error reactsearch@0.1.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the reactsearch@0.1.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 ]