1
resposta

Erro ao rodar "npm start" na pasta do projeto

Estou tentando rodar o "npm start" dentro da pasta do projeto (.../js/projeto-instalura-ssr) e apresenta o seguinte erro:

> instalura-ssr@0.0.1 start /.../js/projeto-instalura-ssr
> if test "$NODE_ENV" = "production"; then npm run prod; else gulp dev; fi

fs.js:27
const { Math, Object } = primordials;
                         ^

ReferenceError: primordials is not defined
    at fs.js:27:26
    at req_ (/.../js/projeto-instalura-ssr/node_modules/natives/index.js:143:24)
    at Object.req [as require] (/.../js/projeto-instalura-ssr/node_modules/natives/index.js:55:10)
    at Object.<anonymous> (/.../js/projeto-instalura-ssr/node_modules/vinyl-fs/node_modules/graceful-fs/fs.js:1:37)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! instalura-ssr@0.0.1 start: `if test "$NODE_ENV" = "production"; then npm run prod; else gulp dev; fi`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the instalura-ssr@0.0.1 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!     /.../.npm/_logs/2019-11-17T18_27_22_874Z-debug.log

Este é arquivo do log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'start' ]
2 info using npm@6.12.0
3 info using node@v12.13.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle instalura-ssr@0.0.1~prestart: instalura-ssr@0.0.1
6 info lifecycle instalura-ssr@0.0.1~start: instalura-ssr@0.0.1
7 verbose lifecycle instalura-ssr@0.0.1~start: unsafe-perm in lifecycle true
8 verbose lifecycle instalura-ssr@0.0.1~start: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/.../js/projeto-instalura-ssr/node_modules/.bin:/opt/lampp/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin
9 verbose lifecycle instalura-ssr@0.0.1~start: CWD: /.../js/projeto-instalura-ssr
10 silly lifecycle instalura-ssr@0.0.1~start: Args: [
10 silly lifecycle   '-c',
10 silly lifecycle   'if test "$NODE_ENV" = "production"; then npm run prod; else gulp dev; fi'
10 silly lifecycle ]
11 silly lifecycle instalura-ssr@0.0.1~start: Returned: code: 1  signal: null
12 info lifecycle instalura-ssr@0.0.1~start: Failed to exec start script
13 verbose stack Error: instalura-ssr@0.0.1 start: `if test "$NODE_ENV" = "production"; then npm run prod; else gulp dev; fi`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:210:5)
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 ChildProcess.emit (events.js:210:5)
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 instalura-ssr@0.0.1
15 verbose cwd /.../js/projeto-instalura-ssr
16 verbose Linux 4.15.0-70-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "start"
18 verbose node v12.13.0
19 verbose npm  v6.12.0
20 error code ELIFECYCLE
21 error errno 1
22 error instalura-ssr@0.0.1 start: `if test "$NODE_ENV" = "production"; then npm run prod; else gulp dev; fi`
22 error Exit status 1
23 error Failed at the instalura-ssr@0.0.1 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
1 resposta

Fala ai Anderson, tudo bem? Esse problema parecer estar ocorrendo por conta de um conflito entre a versão do Node e Gulp.

Qual a versão do seu Node e Gulp? Sugiro você tentar atualizar a versão do Gulp ou realizar o downgrade do Node.

Uma outra possível solução seria rodar esses dois comandos:

npm install -g n
sudo n 11.15.0

Talvez ajude também.

Espero ter ajudado.