Freecodecamp: [Bug] npm run develop does not work on Windows machine

Created on 11 Dec 2018  Â·  17Comments  Â·  Source: freeCodeCamp/freeCodeCamp

Another user (@cmccormack and I who both uses Windows, have run into a problem with the latest master updates when it comes to trying to running npm run develop on our local machines.

See the following when I tried running npm run develop in git-bash:

$ npm run develop

> @freecodecamp/[email protected] develop D:\coding\fcc
> npm-run-all -s ensure-env start-develop


> @freecodecamp/[email protected] ensure-env D:\coding\fcc
> cross-env DEBUG=fcc:* node ./tools/scripts/ensure-env.js

  fcc:tools:ensure-env ignoring creation of redirect file in undefined +0ms
  fcc:tools:ensure-env pathMigration present +11ms

> @freecodecamp/[email protected] start-develop D:\coding\fcc
> node ./tools/scripts/start-develop.js


> @freecodecamp/[email protected] predevelop D:\Coding\fcc\client
> npm run prebuild

Debugger listening on ws://127.0.0.1:9229/ce7034de-7844-41f5-ab4a-bccf273b8f06
For help see https://nodejs.org/en/docs/inspector

> @freecodecamp/[email protected] prebuild D:\Coding\fcc\client
> npm run build:frame-runner && node ../tools/scripts/ensure-env.js


> @freecodecamp/[email protected] build:frame-runner D:\Coding\fcc\client
> webpack --env.production --config ./webpack-frame-runner.js

  fcc:server:datasources using MailHog server on port 1025 +0ms
  fcc:server:utils:about no google applications credentials environmental variable found
  fcc:server:utils:about 'GOOGLE_APPLICATION_CREDENTIALS'
  fcc:server:utils:about 'activeUser' api will always return 0
  fcc:server:utils:about this can safely be ignored during development +3s
  fcc:models:user setting up user hooks +934ms
  fcc:server freeCodeCamp server listening on port 3000 in development +4s
  fcc:server connecting to db at mongodb://localhost:27017/freecodecamp +26ms
Hash: d0144a0e981d544fd117
Version: webpack 4.22.0
Time: 10622ms
Built at: 2018-12-10 19:14:18
                Asset      Size  Chunks             Chunk Names
      frame-runner.js   235 KiB       0  [emitted]  frame-runner
  frame-runner.js.map  1.18 MiB       0  [emitted]  frame-runner
      sass-compile.js  1.13 KiB       1  [emitted]  sass-compile
  sass-compile.js.map  4.89 KiB       1  [emitted]  sass-compile
    test-evaluator.js   156 KiB       2  [emitted]  test-evaluator
test-evaluator.js.map   811 KiB       2  [emitted]  test-evaluator
Entrypoint frame-runner = frame-runner.js frame-runner.js.map
Entrypoint sass-compile = sass-compile.js sass-compile.js.map
Entrypoint test-evaluator = test-evaluator.js test-evaluator.js.map
 [92] (webpack)/buildin/global.js 489 bytes {0} {2} [built]
      ModuleConcatenation bailout: Module is not an ECMAScript module
[320] ./src/client/frame-runner.js 4.13 KiB {0} [built]
      ModuleConcatenation bailout: Module uses eval()
[321] ./src/client/workers/sass-compile.js 253 bytes {1} [built]
      ModuleConcatenation bailout: Module is not an ECMAScript module
[322] ./src/client/workers/test-evaluator.js 2.49 KiB {2} [built]
      ModuleConcatenation bailout: Module uses eval()
    + 324 hidden modules

> @freecodecamp/[email protected] develop D:\Coding\fcc\client
> gatsby develop

  fcc:server db connected +1s

  fcc:boot:donate activeDonator count: 0 +1s
No Stripe API keys were found, moving on...

It hung on that last part. Both @cmccormack and I waited a very long time to no avail.

I even deleted my local repo and re-cloned and still was not able to make it work.

The only way to get it to work is a two create two session windows. In the first session you need to switch to api-server/ and then run node development-entry.js. Once it gets to the same part regarding the "No Stripe API keys were found, moving on...", in the second session, you then run npm run develop and it will finally work and you will see:

You can now view @freecodecamp/client in the browser.

  http://localhost:8000/

View GraphiQL, an in-browser IDE, to explore your site's data and schema

  http://localhost:8000/___graphql

Note that the development build is not optimized.
To create a production build, use gatsby build

i ï½¢wdmï½£:
i ï½¢wdmï½£: Compiled successfully.

@Bouncey This is the same issue you helped @cmccormack work through back on November 27th.

device specific need to test locally needs help for triage

Most helpful comment

@RandellDawson

replace your scripts block with this

"scripts": {
    "postinstall": "npm run bootstrap",
    "prebootstrap": "npm run ensure-env",
    "bootstrap": "lerna bootstrap",
    "clean": "lerna clean",
    "develop": "npm-run-all -s ensure-env && npm-run-all -p start-develop-server start-develop-client",
    "ensure-env": "cross-env DEBUG=fcc:* node ./tools/scripts/ensure-env.js",
    "lint": "echo 'Warning: TODO - Define Linting with fixing.'",
    "seed": "npm-run-all -p seed:*",
    "seed:challenges": "cross-env DEBUG=fcc:* node ./tools/scripts/seed/seedChallenges",
    "seed:news": "cross-env DEBUG=fcc:* node ./tools/scripts/seed/seedNewsArticles",
    "start-develop-client": "cd ./client && node ./node_modules/gatsby-cli develop",
    "start-develop-server": "cd ./api-server && node development-entry.js",
    "pretest": "npm-run-all -s test:lint",
    "test": "npm-run-all -p test:*",
    "test:lint": "echo 'Warning: TODO - Define Linting tests.'",
    "test:client": "cd ./client && npm test && cd ../",
    "test:curriculum": "cd ./curriculum && npm test && cd ../",
    "test:challenge-formatting": "node ./tools/scripts/ci/ensure-challenge-formatting.js",
    "test:guide-formatting": "node ./tools/scripts/ci/ensure-guide-formatting.js",
    "test:server": "cd ./api-server && npm test && cd ../",
    "test:tools": "jest ./tools"
  },

Then try npm run develop again.

All 17 comments

I have an update.

After Ctrl + c to exit and shutting down the gitbash, I opened Windows powershell and was able to run npm run develop and it worked fine. Then, just as a test, I opened git-bash again and ran npm run develop and it worked. As a final test, I rebooted my machine again and gitbash worked with just npm run develop. I am not sure why it works now, but something about getting to that Stripe (donation part in the log) allows it to work after cancelling execution the first time. I am not sure if running successfully in powershell did something in the windows settings which allowed it to work in git-bash or that was a coincidence. I fear others may have a similar experience with Windows. I can no longer replicate, but two of us had the exact same issue.

Another update. If I run npm install again, and repeat the normal process to start the development environment, it still stalls at:

> @freecodecamp/[email protected] develop D:\Coding\fcc\client
> gatsby develop

  fcc:server db connected +1s

  fcc:boot:donate activeDonator count: 0 +1s
No Stripe API keys were found, moving on...

Warning Off Topic Comment Below

Windows has always been a little hostile for doing development for *nix like target system. You are using Git Bash (just meant for doing Git and NOT Node.js) or equivalent for running binaries that were meant for *nix targets.

Ideally, you should be using their windows equivalents like Powershell + Git for Windows + Node.js. These are again 'Yet Another Set of Tools' but more compatible to Windows natively.

Anyways, I think this is more to do with the tooling than the codebase itself. We can try make a setup to understand this better.

That said from my experience these two stacks have played well in the past for a friendlier dev experience:

  1. Windows 7 and Later: Cygwin + Cmder

    • Cmder (a mashup of different programs) gives you a Console emulator, that is 100x better than the default Cmd prompt or Powershell and the Git Bash for Windows.
    • Cygwin is basically a collection of *unix tools ported to work natively in Windows.
  2. Windows 10 and Later: Windows Subsystem for Linux (WSL) + Ubuntu

    • This is an attempt by Windows to be more close to *unix like dev environment and surprisingly is amazing because, you use Ubuntu within Windows, without any VMs, as if Ubuntu were just another app on Windows (this is a complex windows kernel + ubuntu interfacing in reality).

@raisedadead OK, thanks for the info.

WSL is extremely slow when dealing with the FCC repo due to the size, I don't consider it a valid option. Simple commands like git status may take 20+ seconds to run.

I experienced this issue with PowerShell + git for windows as well. However, in PowerShell, I was able to ctrl+c where the process hung and the next process would kick off successfully. This leads me to believe there may be some system call that isn't working as expected in Windows, and if this could be identified we could clear up this issue for other Windows users.

If I had to guess, this block of code in tools/scripts/start-develop.js is where the problem stems:

const loopback = spawn(
  'cd',
  ['./api-server', '&&', 'node development-entry.js'],
  spawnOpts
);
const gatsby = spawn('cd', ['./client', '&&', 'npm run develop'], spawnOpts);

Perhaps the script is waiting for the first call to spawn to complete and isn't receiving the right value or something. Maybe there is another cleaner way to call these processes.

@cmccormack @RandellDawson How does npm test work for you? If all the tests run in parallel, could you see if using npm-run-all fixes this issue?

@Bouncey npm test works fine. When you say use npm-run-all, the npm run develop already does that I thought. When I look a package.json, it shows:

"develop": "npm-run-all -s ensure-env start-develop",` under `"scripts"

What is the exact npm-run-all statement we should try?

@RandellDawson

replace your scripts block with this

"scripts": {
    "postinstall": "npm run bootstrap",
    "prebootstrap": "npm run ensure-env",
    "bootstrap": "lerna bootstrap",
    "clean": "lerna clean",
    "develop": "npm-run-all -s ensure-env && npm-run-all -p start-develop-server start-develop-client",
    "ensure-env": "cross-env DEBUG=fcc:* node ./tools/scripts/ensure-env.js",
    "lint": "echo 'Warning: TODO - Define Linting with fixing.'",
    "seed": "npm-run-all -p seed:*",
    "seed:challenges": "cross-env DEBUG=fcc:* node ./tools/scripts/seed/seedChallenges",
    "seed:news": "cross-env DEBUG=fcc:* node ./tools/scripts/seed/seedNewsArticles",
    "start-develop-client": "cd ./client && node ./node_modules/gatsby-cli develop",
    "start-develop-server": "cd ./api-server && node development-entry.js",
    "pretest": "npm-run-all -s test:lint",
    "test": "npm-run-all -p test:*",
    "test:lint": "echo 'Warning: TODO - Define Linting tests.'",
    "test:client": "cd ./client && npm test && cd ../",
    "test:curriculum": "cd ./curriculum && npm test && cd ../",
    "test:challenge-formatting": "node ./tools/scripts/ci/ensure-challenge-formatting.js",
    "test:guide-formatting": "node ./tools/scripts/ci/ensure-guide-formatting.js",
    "test:server": "cd ./api-server && npm test && cd ../",
    "test:tools": "jest ./tools"
  },

Then try npm run develop again.

@Bouncey That seems to have done the trick. For me, it completes with no issues now using npm run develop with the changes you made above.

Awesome

I tested PR #34840 locally and it seems to have worked to get the server running. However, I seem to be having issues killing the process when I'm done. In PowerShell, none of the kill commands seemed to work, but when I tried to close the PowerShell window I was hit with the following errors:

error UNHANDLED EXCEPTION
npm ERR! code ELIFECYCLE
npm ERR! errno 3221225786
npm ERR! @freecodecamp/[email protected] start-develop-server: `cd ./api-server && node development-entry.js`
npm ERR! Exit status 3221225786
npm ERR!
npm ERR! Failed at the @freecodecamp/[email protected] start-develop-server 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\chris\AppData\Roaming\npm-cache\_logs\2019-01-09T17_44_23_192Z-debug.log


  Error: kill ENOSYS

  - process.js:183 process.kill
    internal/process.js:183:18

  - index.js:95 process.listener
    [client]/[signal-exit]/index.js:95:15

  - index.js:155 processEmit
    [client]/[signal-exit]/index.js:155:32

  - process.js:208 Signal.wrap.onsignal
    internal/process.js:208:44


ERROR: "start-develop-server" exited with 3221225786.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @freecodecamp/[email protected] develop: `npm-run-all -s ensure-env && npm-run-all -p start-develop-server start-develop-client`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @freecodecamp/[email protected] develop 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\chris\AppData\Roaming\npm-cache\_logs\2019-01-09T17_44_23_658Z-debug.log

Hopefully these errors provide some insight.

Thanks for looking into this @Bouncey !

Edit: Found this issue that seems similar and they have some commits that may have fixed the issue.

@cmccormack could you remove --silent from this line and try again?

https://github.com/freeCodeCamp/freeCodeCamp/blob/05535d1e56bca7456b69510fa724493edf5fa1ca/api-server/development-entry.js#L7

That should output some errors to the console when you try to exit.

@Bouncey I didn't see any errors when removing the --silent flag. I did notice that the ability to kill the process seems inconsistent, after checking out this PR again and resetting everything and running develop, I couldn't kill the process through normal means. After several tries I am able to more consistently kill the process, though - not sure why.

Sorry did not mean to close the issue, auto-pilot took over...

@RandellDawson

replace your scripts block with this

"scripts": {
    "postinstall": "npm run bootstrap",
    "prebootstrap": "npm run ensure-env",
    "bootstrap": "lerna bootstrap",
    "clean": "lerna clean",
    "develop": "npm-run-all -s ensure-env && npm-run-all -p start-develop-server start-develop-client",
    "ensure-env": "cross-env DEBUG=fcc:* node ./tools/scripts/ensure-env.js",
    "lint": "echo 'Warning: TODO - Define Linting with fixing.'",
    "seed": "npm-run-all -p seed:*",
    "seed:challenges": "cross-env DEBUG=fcc:* node ./tools/scripts/seed/seedChallenges",
    "seed:news": "cross-env DEBUG=fcc:* node ./tools/scripts/seed/seedNewsArticles",
    "start-develop-client": "cd ./client && node ./node_modules/gatsby-cli develop",
    "start-develop-server": "cd ./api-server && node development-entry.js",
    "pretest": "npm-run-all -s test:lint",
    "test": "npm-run-all -p test:*",
    "test:lint": "echo 'Warning: TODO - Define Linting tests.'",
    "test:client": "cd ./client && npm test && cd ../",
    "test:curriculum": "cd ./curriculum && npm test && cd ../",
    "test:challenge-formatting": "node ./tools/scripts/ci/ensure-challenge-formatting.js",
    "test:guide-formatting": "node ./tools/scripts/ci/ensure-guide-formatting.js",
    "test:server": "cd ./api-server && npm test && cd ../",
    "test:tools": "jest ./tools"
  },

Then try npm run develop again.

This script block change fixed my problem running it locally. I look forward to having it merged into master. Thanks @Bouncey
I did not have any issues killing the process.

@RandellDawson @cmccormack @scissorsneedfoodtoo, I cannot help any further on this as I do not have a windows machine.

Any input to further this issue would be much appreciated

@Bouncey I have the same problem killing the process. However, if I run git bash as admin I can kill the process.

BTW. "npm run seed" failes for me with the script posted here https://github.com/freeCodeCamp/freeCodeCamp/issues/34627#issuecomment-452670750.

I'm on Win7 x64

Was this page helpful?
0 / 5 - 0 ratings

Related issues

imhuyqn picture imhuyqn  Â·  3Comments

jurijuri picture jurijuri  Â·  3Comments

trashtalka3000 picture trashtalka3000  Â·  3Comments

bagrounds picture bagrounds  Â·  3Comments

kokushozero picture kokushozero  Â·  3Comments