Je travaille sur une application React. Lorsque j'utilise la commande npm start, cela donne une erreur. J'ai essayé de supprimer node_modules et package-lock.json, puis de faire npm install. J'ai aussi essayé de faire npm cache clean --force. La dernière chose que j'ai faite a été npm audit fix. J'ai toujours le même problème. Voici mon erreur :

> majestic-bay@0.1.0 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! majestic-bay@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the majestic-bay@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!     /home/serg/.npm/_logs/2020-11-06T06_52_29_568Z-debug.log

Voici mon 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"
        ]
    }
}

Voici le contenu du fichier d'erreur :

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 npm@6.14.8
3 info using node@v9.11.2
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle majestic-bay@0.1.0~prestart: majestic-bay@0.1.0
6 info lifecycle majestic-bay@0.1.0~start: majestic-bay@0.1.0
7 verbose lifecycle majestic-bay@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle majestic-bay@0.1.0~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 majestic-bay@0.1.0~start: CWD: /home/serg/webdev/majestic-bay
10 silly lifecycle majestic-bay@0.1.0~start: Args: [ '-c', 'react-scripts start' ]
11 silly lifecycle majestic-bay@0.1.0~start: Returned: code: 1  signal: null
12 info lifecycle majestic-bay@0.1.0~start: Failed to exec start script
13 verbose stack Error: majestic-bay@0.1.0 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 majestic-bay@0.1.0
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 majestic-bay@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the majestic-bay@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 ]
6
in43sh 6 nov. 2020 à 10:37

1 réponse

Meilleure réponse

C'était donc la version node. J'avais la v9.11.2, donc quand j'ai installé la version v12.19.0, ça l'a corrigé.

5
in43sh 6 nov. 2020 à 23:05