0

I'm new to node and react and am trying to start a local development server for my react app. To start it I did npm start but this put out an error. The log looks like this:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.14.4
3 info using node@v12.16.3
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle myapp@0.1.0~prestart: myapp@0.1.0
6 info lifecycle myapp@0.1.0~start: myapp@0.1.0
7 verbose lifecycle myapp@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle myapp@0.1.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;E:\full-stack projects\react tutoral\myapp\node_modules\.bin;C:\Program Files\Git\mingw32\bin;C:\Program Files\Git\usr\bin;C:\Users\User\bin;C:\Program Files\Microsoft SDKs\Azure\CLI2\wbin;C:\Program Files\PostgreSQL\10\bin;C:\Program Files\PostgreSQL\10\libC;C:\Program Files\Git\Python27;C:\Python27\scripts;C:\Users\User\AppData\Local\Programs\Python\Python37-32;C:\Users\User\AppData\Local\Programs\Python\Python37-32\Scripts;C:\Program Files\nodejs;C:\Users\User\AppData\Local\Programs\Microsoft VS Code\bin;C:\Program Files\heroku\bin;C:\Users\User\AppData\Roaming\npm
9 verbose lifecycle myapp@0.1.0~start: CWD: E:\full-stack projects\react tutoral\myapp
10 silly lifecycle myapp@0.1.0~start: Args: [ '/d /s /c', 'react-scripts start' ]
11 silly lifecycle myapp@0.1.0~start: Returned: code: 1  signal: null
12 info lifecycle myapp@0.1.0~start: Failed to exec start script
13 verbose stack Error: myapp@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:310:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:310:20)
13 verbose stack     at maybeClose (internal/child_process.js:1021:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid myapp@0.1.0
15 verbose cwd E:\full-stack projects\react tutoral\myapp
16 verbose Windows_NT 6.1.7601
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v12.16.3
19 verbose npm  v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error myapp@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the myapp@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

How do I fix this?

EDIT

Here is the package.json for the app:

{
  "name": "myapp",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.5.0",
    "@testing-library/user-event": "^7.2.1",
    "react": "^16.13.1",
    "react-dom": "^16.13.1",
    "react-scripts": "3.4.1"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts 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"
    ]
  }
}

EDIT 2 I have tried all the solutions suggested, but it always shows the same errror. Here is how the error is shown in the termianl (bash):

events.js:287
      throw er; // Unhandled 'error' event
      ^

Error: spawn cmd ENOENT
←[90m    at Process.ChildProcess._handle.onexit (internal/child_process.js:267:19)←[39m
←[90m    at onErrorNT (internal/child_process.js:469:16)←[39m
←[90m    at processTicksAndRejections (internal/process/task_queues.js:84:21)←[39m
Emitted 'error' event on ChildProcess instance at:
←[90m    at Process.ChildProcess._handle.onexit (internal/child_process.js:273:12)←[39m
←[90m    at onErrorNT (internal/child_process.js:469:16)←[39m
←[90m    at processTicksAndRejections (internal/process/task_queues.js:84:21)←[39m {
  errno: ←[32m'ENOENT'←[39m,
  code: ←[32m'ENOENT'←[39m,
  syscall: ←[32m'spawn cmd'←[39m,
  path: ←[32m'cmd'←[39m,
  spawnargs: [ ←[32m'/s'←[39m, ←[32m'/c'←[39m, ←[32m'start'←[39m, ←[32m'""'←[39m, ←[32m'/b'←[39m, ←[32m'"http://localhost:3000"'←[39m ]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2020-05-07T16_48_16_197Z-debug.log

ignore this line. Stackoverflow requires me to describe the problem in details since most of this is code

iscream
  • 680
  • 2
  • 8
  • 20
  • Can you share your `package.json` code? – praveen-me May 07 '20 at 16:02
  • @praveen-me please check the edit – iscream May 07 '20 at 16:08
  • Have you tried, removing node_modules and then run `npm i` and `npm start` again? – praveen-me May 07 '20 at 16:09
  • How do I remove them? should I just delete the folder? – iscream May 07 '20 at 16:10
  • Just inside your app. Go to terminal and run `rm -rf node_modules package-lock.json && npm i && npm start`. See if it works. – praveen-me May 07 '20 at 16:12
  • Nope it still produces an error. One thing I have noticed is that during the installation it probably skipped a few dependencies, may thats normal? – iscream May 07 '20 at 16:30
  • It is an issue with heap out of memory, Try this [https://stackoverflow.com/questions/55613789/how-to-fix-fatal-error-ineffective-mark-compacts-near-heap-limit-allocation-fa?noredirect=1&lq=1 ](javascript heap error) Hope this helps – Nitin May 07 '20 at 16:37

1 Answers1

1

Ok so this problem was with the Windows system32 variable. Its actually really easy to solve. Just add the following to the PATH variable:

C:\Windows\System32
iscream
  • 680
  • 2
  • 8
  • 20