Solucionado (ver solução)
Solucionado
(ver solução)
2
respostas

Depois de rodar o npm install no arquivo do projeto que baixei do git hub, que vocês disponibilizaram aqui, eu tentei usar o 'npm start', e recebi esse erro:

E:\alura\react-pt3\last-version>npm start

> instalura-ssr@0.0.1 start E:\alura\react-pt3\last-version
> if test "$NODE_ENV" = "production"; then npm run prod; else gulp dev; fi

"$NODE_ENV" foi inesperado neste momento.
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!     C:\Users\MarceloPN\AppData\Roaming\npm-cache\_logs\2019-08-22T18_58_52_597Z-debug.log

E:\alura\react-pt3\last-version>

Como procedo?

Esse é o conteúdo do log:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start' ]
2 info using npm@6.9.0
3 info using node@v10.16.3
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: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;E:\alura\react-pt3\last-version\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Program Files\MySQL\MySQL Utilities 1.6\;C:\Program Files\MySQL\MySQL Server 5.7\bin;C:\Program Files\nodejs\;C:\Ruby25-x64\bin;C:\Program Files\MySQL\MySQL Shell 8.0\bin\;C:\Users\MarceloPN\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\MarceloPN\AppData\Roaming\npm
9 verbose lifecycle instalura-ssr@0.0.1~start: CWD: E:\alura\react-pt3\last-version
10 silly lifecycle instalura-ssr@0.0.1~start: Args: [ '/d /s /c',
10 silly lifecycle   'if test "$NODE_ENV" = "production"; then npm run prod; else gulp dev; fi' ]
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> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid instalura-ssr@0.0.1
15 verbose cwd E:\alura\react-pt3\last-version
16 verbose Windows_NT 10.0.17134
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v10.16.3
19 verbose npm  v6.9.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 ]

No arquivo package.json na parte "scripts" tá assim:

 "scripts": {
    "start": "if test \"$NODE_ENV\" = \"production\"; then npm run prod; else gulp dev; fi",
    "test": "gulp check",
    "coverage": "gulp check",
    "prod": "echo 'Starting standalone server in PROD mode'; node .",
    "heroku-postbuild": "gulp build"
  }
2 respostas

Baseado no que está em "scripts", "start", eu rodei o camndo "gulp dev" diretamente no terminal da pasta do projeto. Parece ter funcionado.

Isso foi o que retornou:

E:\alura\react-pt3\instalura-ssr>gulp dev
[20:16:38] Using gulpfile E:\alura\react-pt3\instalura-ssr\gulpfile.js
[20:16:38] Starting 'dev'...
[20:16:38] Starting '.webpack-dev'...
[20:16:38] Finished '.webpack-dev' after 353 μs
[20:16:38] Starting 'wds.dev'...
[20:16:38] Starting 'server-watch-$deps$'...
[20:16:38] Starting '.init-bundle.valid.log'...
[20:16:38] Finished '.init-bundle.valid.log' after 5.77 ms
[20:16:38] Finished 'server-watch-$deps$' after 12 ms
[20:16:38] Starting 'server-watch'...
[20:16:38] Starting 'generate-service-worker'...
[20:16:38] Finished 'generate-service-worker' after 768 μs
[nodemon] 1.19.1
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: .etmp\bundle.valid.log E:\alura\react-pt3\instalura-ssr\src\server/**/* E:\alura\react-pt3\instalura-ssr\config/**/*
Just FYI: Entry point configuration is not found, using default entry point... - optional module not found; Path "E:\alura\react-pt3\instalura-ssr\src\client\entry.config.js"
isomorphic-loader webpack plugin: removed existing config file
Just FYI: optional module not found; Path "E:\alura\react-pt3\instalura-ssr\config\sw-config.js"
Just FYI: optional module not found; Path "E:\alura\react-pt3\instalura-ssr\config\default.json"              0% compile http://localhost:2992/webpack-dev-server/
webpack result is served from http://localhost:2992/js/
content is served from E:\alura\react-pt3\instalura-ssr      webpack bundle is now VALID
webpack report is served from http://localhost:2992/reporter
[nodemon] restarting due to changes...
[nodemon] starting `babel-node src\server\index.js`
farmhash module not available, turning off hashKey
Just FYI: APP_SRC_DIR set to src/
Just FYI: optimizeModulesForProduction - skipping since NODE_ENV !== "production"
 > isomorphic-loader extend require: config is now VALID - webpack dev server mode <
Warning: Accessing PropTypes via the main React package is deprecated, and will be removed in  React v16.0. Use the latest available v15.* prop-types package from npm instead. For info on usage, compatibility, migration and more, see https://fb.me/prop-types-docs

Hapi.js server running at http://DESKTOP-SGBCVI1:3000

Posso considerar resolvido?

solução!

Fala aí Marcelo, tudo bem? Olhando os logs acredito que sim, parece que usou as configurações e módulos necessários e subiu o servidor na porta 3000.

Faça um teste na aplicação e veja se tudo está funcionando corretamente, se sim, show.

Espero ter ajudado.

Quer mergulhar em tecnologia e aprendizagem?

Receba a newsletter que o nosso CEO escreve pessoalmente, com insights do mercado de trabalho, ciência e desenvolvimento de software