7

I'm working on a React application. When I'm using the command npm start, it gives an error. I tried deleting node_modules and package-lock.json and then doing npm install. I also tried doing npm cache clean --force. The last thing I did was npm audit fix. I still have the same issue. Here is my error:

> [email protected] start /home/serg/webdev/majestic-bay
> react-scripts start

/home/serg/webdev/majestic-bay/node_modules/terser-webpack-plugin/node_modules/p-limit/index.js:30
                } catch {}
                        ^

SyntaxError: Unexpected token {
    at new Script (vm.js:51:7)
    at createScript (vm.js:136:10)
    at Object.runInThisContext (vm.js:197:10)
    at Module._compile (internal/modules/cjs/loader.js:618:28)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:665:10)
    at Module.load (internal/modules/cjs/loader.js:566:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:506:12)
    at Function.Module._load (internal/modules/cjs/loader.js:498:3)
    at Module.require (internal/modules/cjs/loader.js:598:17)
    at require (internal/modules/cjs/helpers.js:11:18)
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!     /home/serg/.npm/_logs/2020-11-06T06_52_29_568Z-debug.log

Here is my package.json:

{
    "name": "majestic-bay",
    "version": "0.1.0",
    "private": true,
    "dependencies": {
        "@testing-library/jest-dom": "^5.11.4",
        "@testing-library/react": "^11.1.0",
        "@testing-library/user-event": "^12.1.10",
        "react": "^17.0.1",
        "react-dom": "^17.0.1",
        "react-scripts": "4.0.0",
        "web-vitals": "^0.2.4"
    },
    "scripts": {
        "start": "react-scripts start",
        "build": "react-scripts build",
        "test": "react-scripts test",
        "eject": "react-scripts eject"
    },
    "eslintConfig": {
        "extends": [
        "react-app",
        "react-app/jest"
        ]
    },
    "browserslist": {
        "production": [
        ">0.2%",
        "not dead",
        "not op_mini all"
        ],
        "development": [
        "last 1 chrome version",
        "last 1 firefox version",
        "last 1 safari version"
        ]
    }
}

Here is the content of the error file:

0 info it worked if it ends with ok
1 verbose cli [ '/home/serg/.nvm/versions/node/v9.11.2/bin/node',
1 verbose cli   '/home/serg/.nvm/versions/node/v9.11.2/bin/npm',
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: /home/serg/.nvm/versions/node/v9.11.2/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/serg/webdev/majestic-bay/node_modules/.bin:/home/serg/.nvm/versions/node/v9.11.2/bin:/home/serg/.local/bin:/home/serg/.local/bin:/usr/local/sbin:/usr/local/bin:/usr/bin:/opt/cxoffice/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl:/var/lib/snapd/snap/bin:/opt/cxoffice/bin:/home/serg/.yarn/bin:/home/serg/.yarn/bin
9 verbose lifecycle [email protected]~start: CWD: /home/serg/webdev/majestic-bay
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> (/home/serg/.nvm/versions/node/v9.11.2/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:180:13)
13 verbose stack     at ChildProcess.<anonymous> (/home/serg/.nvm/versions/node/v9.11.2/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:180:13)
13 verbose stack     at maybeClose (internal/child_process.js:936:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/serg/webdev/majestic-bay
16 verbose Linux 5.8.18-1-MANJARO
17 verbose argv "/home/serg/.nvm/versions/node/v9.11.2/bin/node" "/home/serg/.nvm/versions/node/v9.11.2/bin/npm" "start"
18 verbose node v9.11.2
19 verbose npm  v6.14.8
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 ]
8
  • Delete the node module and run npm install again Commented Nov 6, 2020 at 7:44
  • @tadman yes, but I don't have it in package.json file. How do I update it then? Commented Nov 6, 2020 at 7:44
  • @SohailAshraf I tried it many times. It's not the issue for sure. Commented Nov 6, 2020 at 7:45
  • terser-webpack-plugin seems to have a bad dependency, so remove it and re-add it to get the latest version, or use an update checking package. If this is a bad version you may need to force downgrade to a specific working version, plus file a bug report if you can. Commented Nov 6, 2020 at 7:45
  • @tadman ok but how do I remove it if I don't have it in the package.json? Commented Nov 6, 2020 at 7:54

1 Answer 1

15

So, it was the node version. I had v9.11.2, so when I installed version v12.19.0, it fixed it.

Sign up to request clarification or add additional context in comments.

1 Comment

If you have to get this running under an older version of node.js (in my case v8.x), downgrading react-scripts to 3.4.2 (terser-webpack-plugin is a dependency) enabled me to dev & build without errors.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.