Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is npm react-scripts producing a syntax error when I run `npm run start`? [duplicate]

So I've been working on a full stack React app for a few months now. For some reason, seemingly out of no where, when I tried to run npm run start on the command line, it produced the following error;

// npm run start

> [email protected] start /Users/eden/Documents/GitHub/Pair./pair
> react-scripts start

/Users/eden/Documents/GitHub/Pair./pair/node_modules/react-dev-utils/WebpackDevServerUtils.js:166
  compiler.hooks.done.tap('done', async stats => {
                                  ^^^^^

SyntaxError: missing ) after argument list
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:542:28)
    at Object.Module._extensions..js (module.js:579:10)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)
    at Module.require (module.js:497:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/eden/Documents/GitHub/Pair./pair/node_modules/react-scripts/scripts/start.js:45:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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!     /Users/eden/.npm/_logs/2019-02-11T01_36_36_244Z-debug.log

I've tried the following approaches;

  • uninstalling/reinstalling node
  • uninstalling/reinstalling npm
  • Ensuring node and npm were version 6 or higher
  • deleting node_modules and package-lock.json and re-running npm-i
  • uninstalling/reinstalling react-scripts
  • downgrading react-scripts
  • running npm install --save react react-dom react-scripts
  • uninstalling/reinstalling react-dev-utils

I even tried copying/pasting contents of WebpackDevServerUtils.js in the GitHub homepage of react-dev-utils to my local node_modules/react-dev-utils/WebpackDevServerUtils.js to resolve the syntax error.

I have no idea why this is happening. Below is the log of this run;

0 info it worked if it ends with ok
1 verbose cli [ '/Users/eden/.nvm/versions/node/v6.11.2/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle [email protected]~prestart: [email protected]
6 info lifecycle [email protected]~start: [email protected]
7 verbose lifecycle [email protected]~start: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/eden/Documents/GitHub/Pair./pair/node_modules/.bin:/Users/eden/.nvm/versions/node/v6.11.2/bin:/Applications/Postgres.app/Contents/Versions/latest/bin:/usr/local:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/Postgres.app/Contents/Versions/latest/bin:/Users/eden/.rvm/bin
9 verbose lifecycle [email protected]~start: CWD: /Users/eden/Documents/GitHub/Pair./pair
10 silly lifecycle [email protected]~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle [email protected]~start: Returned: code: 1  signal: null
12 info lifecycle [email protected]~start: Failed to exec start script
13 verbose stack Error: [email protected] start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at emitTwo (events.js:106:13)
13 verbose stack     at EventEmitter.emit (events.js:191:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at emitTwo (events.js:106:13)
13 verbose stack     at ChildProcess.emit (events.js:191:7)
13 verbose stack     at maybeClose (internal/child_process.js:891:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
14 verbose pkgid [email protected]
15 verbose cwd /Users/eden/Documents/GitHub/Pair./pair
16 verbose Darwin 18.2.0
17 verbose argv "/Users/eden/.nvm/versions/node/v6.11.2/bin/node" "/usr/local/bin/npm" "run" "start"
18 verbose node v6.11.2
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] start: `react-scripts start`
22 error Exit status 1
23 error Failed at the [email protected] start 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 looked at line 166 of WebpackDevServerUtils.js, and used ESLint to ID syntax errors and it couldn't find anything.

Consequently, my question is this: How do I resolve this obscure error?

like image 622
user10750437 Avatar asked Feb 11 '19 01:02

user10750437


People also ask

Why does npm run start not work?

If you see the start script is present inside your package. json file but still can't run the script, you need to check the console output. If there's no output at all, then you may have the ignore-scripts npm configuration set to true .

How do I fix SH 1 react-scripts not found?

Run the npm install react-scripts command to solve the "react-scripts: command not found" error. If necessary delete your node_modules directory and your package-lock. json file, reinstall your dependencies and restart your development server.


1 Answers

The error seems to be on async and you are using node 6 which doesn't support async / await. Update to the latest version of node that supports it (7.6) and you should be good.

like image 166
user2989598 Avatar answered Oct 18 '22 23:10

user2989598