8
respostas

NPM Start apresenta erro.

Olá, peguei o projeto atualizado em https://cursos.alura.com.br/course/react-parte-3/task/25121, e após rodar npm install e npm start, recebo o seguinte erro:

(react) workdb@wdb-tec008:~/Desktop/Alura/Engenheiro front-end./React/instalura$ npm start

> instalura-ssr@0.0.1 start /home/workdb/Desktop/Alura/Engenheiro front-end./React/instalura
> if test "$NODE_ENV" = "production"; then npm run prod; else gulp dev; fi

module.js:549
    throw err;
    ^

Error: Cannot find module 'electrode-archetype-react-app'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/home/workdb/Desktop/Alura/Engenheiro front-end./React/instalura/gulpfile.js:1:63)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
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!     /home/workdb/.npm/_logs/2019-02-16T13_10_39_362Z-debug.log
8 respostas

Criei um novo env, utilizei o mesmo projeto do git, e dei novamente npm install e após, npm start. Agora obtive novos erros:

npm -v
3.5.2

node -v
v8.10.0
(instalura) workdb@wdb-tec008:~/Desktop/Alura/Engenheiro front-end./React/instalura$ npm start

> instalura-ssr@0.0.1 start /home/workdb/Desktop/Alura/Engenheiro front-end./React/instalura
> if test "$NODE_ENV" = "production"; then npm run prod; else gulp dev; fi

[12:21:16] Using gulpfile ~/Desktop/Alura/Engenheiro front-end./React/instalura/gulpfile.js
[12:21:16] Starting 'dev'...
[12:21:16] Starting '.webpack-dev'...
[12:21:16] Finished '.webpack-dev' after 110 μs
[12:21:16] Starting 'wds.dev'...
[12:21:16] Starting 'server-watch-$deps$'...
[12:21:16] Starting '.init-bundle.valid.log'...
[12:21:16] Finished '.init-bundle.valid.log' after 295 μs
[12:21:16] Finished 'server-watch-$deps$' after 7.22 ms
[12:21:16] Starting 'server-watch'...
[12:21:16] Starting 'generate-service-worker'...
[12:21:16] Finished 'generate-service-worker' after 277 μs
[nodemon] 1.18.10
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: .etmp/bundle.valid.log /home/workdb/Desktop/Alura/Engenheiro front-end./React/instalura/src/server/**/* /home/workdb/Desktop/Alura/Engenheiro front-end./React/instalura/config/**/*
module.js:549
    throw err;
    ^

Error: Cannot find module '/home/workdb/Desktop/Alura/Engenheiro'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at module.exports (/home/workdb/Desktop/Alura/Engenheiro front-end./React/instalura/node_modules/webpack/bin/convert-argv.js:80:13)
    at Object.<anonymous> (/home/workdb/Desktop/Alura/Engenheiro front-end./React/instalura/node_modules/webpack-dev-server/bin/webpack-dev-server.js:68:48)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
[12:21:16] 'wds.dev' errored after 654 ms
[12:21:16] Error: command exit code 1
    at error (/home/workdb/Desktop/Alura/Engenheiro front-end./React/instalura/node_modules/electrode-gulp-helper/lib/exec.js:6:15)
    at shell.exec (/home/workdb/Desktop/Alura/Engenheiro front-end./React/instalura/node_modules/electrode-gulp-helper/lib/exec.js:39:29)
    at /home/workdb/Desktop/Alura/Engenheiro front-end./React/instalura/node_modules/shelljs/src/exec.js:204:9
    at ChildProcess.exithandler (child_process.js:282:5)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
[12:21:16] 'dev' errored after 656 ms
[12:21:16] Error in plugin 'run-sequence(wds.dev)'
Message:
    command exit code 1

Criei um novo env e refiz tudo, mas desta vez, com o node e npm em sua última versão estável. Porém o erro anterior persistiu.

 node -v
v11.10.0

 npm -v
6.7.0

Fala aí Nícolas, tudo bem? Você fez a instalação das dependência do projeto?

Antes de tentar subir, rode o install:

npm i
// ou
npm install

Após concluir todo download ai você pode tentar subir:

npm start

Espero ter ajudado.

Opa Matheus, como comentei nas 3 mensagens anteriores, nos 3 testes que realizei, dei npm install, e após, npm start, porém o erro persiste. No último teste, em que controlei a versão do Node e NPM, eu cheguei a desinstalar o Node e instalar novamente, antes de dar o NPM install e npm start.

Eu fiz o teste aqui e deu tudo certo Nicolas, baixei o projeto:

https://github.com/alberto-alura/projeto-instalura-ssr/archive/codigo-ponto-partida.zip

Rodei:

npm i
npm start

E subiu certinho.

Você fez alguma modificação após pegar o projeto pronto?

Matheus, bom dia! Consegue me informar qual a sua versão de node e npm? Vou tentar desintalar o node e controlar a versão por nvm para uma igual a sua.

Opa, segue:

  • Node: 10.14.1
  • npm: 6.8.0

Espero ter ajudado.

Criei uma VM nova do meu SO e instalei a mesma versão de Node que você, ao baixar o projeto e rodar npm i, o seguinte ocorreu:

farmhash@1.2.1 install /home/ubuntu/Desktop/projeto-instalura-ssr-conclusao/node_modules/farmhash
node-gyp rebuild


gyp ERR! build error 
gyp ERR! stack Error: not found: make
gyp ERR! stack     at getNotFoundError (/home/ubuntu/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/which/which.js:13:12)
gyp ERR! stack     at F (/home/ubuntu/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/which/which.js:68:19)
gyp ERR! stack     at E (/home/ubuntu/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack     at /home/ubuntu/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack     at /home/ubuntu/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/isexe/index.js:42:5
gyp ERR! stack     at /home/ubuntu/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
gyp ERR! stack     at FSReqWrap.oncomplete (fs.js:154:21)
gyp ERR! System Linux 4.18.0-15-generic
gyp ERR! command "/home/ubuntu/.nvm/versions/node/v10.14.1/bin/node" "/home/ubuntu/.nvm/versions/node/v10.14.1/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/ubuntu/Desktop/projeto-instalura-ssr-conclusao/node_modules/farmhash
gyp ERR! node -v v10.14.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

phantomjs-prebuilt@2.1.16 install /home/ubuntu/Desktop/projeto-instalura-ssr-conclusao/node_modules/phantomjs-prebuilt
node install.js


PhantomJS not found on PATH
Downloading https://github.com/Medium/phantomjs/releases/download/v2.1.1/phantomjs-2.1.1-linux-x86_64.tar.bz2
Saving to /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2
Receiving...
  [========================================] 99%
Received 22866K total.
Extracting tar contents (via spawned process)
Removing /home/ubuntu/Desktop/projeto-instalura-ssr-conclusao/node_modules/phantomjs-prebuilt/lib/phantom
Copying extracted folder /tmp/phantomjs/phantomjs-2.1.1-linux-x86_64.tar.bz2-extract-1551548150871/phantomjs-2.1.1-linux-x86_64 -> /home/ubuntu/Desktop/projeto-instalura-ssr-conclusao/node_modules/phantomjs-prebuilt/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /home/ubuntu/Desktop/projeto-instalura-ssr-conclusao/node_modules/phantomjs-prebuilt/lib/phantom/bin/phantomjs

nodemon@1.18.10 postinstall /home/ubuntu/Desktop/projeto-instalura-ssr-conclusao/node_modules/nodemon
node bin/postinstall || exit 0


Love nodemon? You can now support the project via the open collective:
 > https://opencollective.com/nodemon/donate

npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN material-ui@0.16.7 requires a peer of react-tap-event-plugin@^1.0.0 || ^2.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.7 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.7: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: farmhash@1.2.1 (node_modules/farmhash):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: farmhash@1.2.1 install: node-gyp rebuild
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1

added 1922 packages from 1799 contributors and audited 23005 packages in 177.35s
found 58 vulnerabilities (25 low, 12 moderate, 19 high, 2 critical)
  run npm audit fix to fix them, or npm audit for details
ubuntu@ubuntu:~/Desktop/projeto-instalura-ssr-conclusao$

E após dar npm start: https://gist.github.com/OPrange/9296c3f41b68526fdd442f4735425e4b