Setting Up fCC Locally

Hello all,

Since the merge of the Python curriculum, I have encountered certain issues with setting up locally:

I get this error with npm ci

node-gyp error

C:\Users\shauh\Documents\freeCodeCamp\freeCodeCamp\node_modules\fsevents>if not defined npm_config_node_gyp (node “C:\Users\shauh\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin\…..\node_modules\node-gyp\bin\node-gyp.js” rebuild ) else (node “C:\Users\shauh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js” rebuild )
gyp ERR! find VS
gyp ERR! find VS msvs_version not set from command line or npm config
gyp ERR! find VS VCINSTALLDIR not set, not running in VS Command Prompt
gyp ERR! find VS could not use PowerShell to find Visual Studio 2017 or newer
gyp ERR! find VS looking for Visual Studio 2015
gyp ERR! find VS - not found
gyp ERR! find VS not looking for VS2013 as it is only supported up to Node.js 8
gyp ERR! find VS
gyp ERR! find VS **************************************************************
gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the “Desktop development with C++” workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS GitHub - nodejs/node-gyp: Node.js native addon build tool
gyp ERR! find VS **************************************************************
gyp ERR! find VS
gyp ERR! configure error
gyp ERR! stack Error: Could not find any Visual Studio installation to use
gyp ERR! stack at VisualStudioFinder.fail (C:\Users\shauh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:121:47)
gyp ERR! stack at C:\Users\shauh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:74:16
gyp ERR! stack at VisualStudioFinder.findVisualStudio2013 (C:\Users\shauh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:351:14)
gyp ERR! stack at C:\Users\shauh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:70:14
gyp ERR! stack at C:\Users\shauh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\find-visualstudio.js:372:16
gyp ERR! stack at C:\Users\shauh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:54:7
gyp ERR! stack at C:\Users\shauh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\util.js:33:16
gyp ERR! stack at ChildProcess.exithandler (child_process.js:297:5)
gyp ERR! stack at ChildProcess.emit (events.js:200:13)
gyp ERR! stack at maybeClose (internal/child_process.js:1021:16)
gyp ERR! System Windows_NT 10.0.19041
gyp ERR! command “C:\Program Files\nodejs\node.exe” “C:\Users\shauh\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js” “rebuild”
gyp ERR! cwd C:\Users\shauh\Documents\freeCodeCamp\freeCodeCamp\node_modules\fsevents
gyp ERR! node -v v12.4.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok

Specifically, this appears to be looking for something to do with Visual Studio:

gyp ERR! find VS You need to install the latest version of Visual Studio
gyp ERR! find VS including the “Desktop development with C++” workload.
gyp ERR! find VS For more information consult the documentation at:
gyp ERR! find VS GitHub - nodejs/node-gyp: Node.js native addon build tool

Then I sometimes get this error with npm run develop

Unable to server

Thu, 28 May 2020 11:41:15 GMT fcc:models:user setting up user hooks
(node:2824) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.
Thu, 28 May 2020 11:41:28 GMT fcc:server freeCodeCamp server listening on port 3000 in development
Thu, 28 May 2020 11:41:28 GMT fcc:server connecting to db at mongodb://localhost:27017/freecodecamp
Connection fails: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connection timed out
at connectionFailureError (C:\Users\shauh\Documents\freeCodeCamp\freeCodeCamp\api-server\node_modules\mongodb\lib\core\connection\connect.js:406:14)
at Socket. (C:\Users\shauh\Documents\freeCodeCamp\freeCodeCamp\api-server\node_modules\mongodb\lib\core\connection\connect.js:294:16)
at Object.onceWrapper (events.js:288:20)
at Socket.emit (events.js:200:13)
at Socket.EventEmitter.emit (domain.js:471:20)
at Socket._onTimeout (net.js:432:8)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7) {
name: ‘MongoNetworkError’,
[Symbol(mongoErrorContextSymbol)]: {}
}]
It will be retried for the next request.
MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connection timed out
at connectionFailureError (C:\Users\shauh\Documents\freeCodeCamp\freeCodeCamp\api-server\node_modules\mongodb\lib\core\connection\connect.js:406:14)
at Socket. (C:\Users\shauh\Documents\freeCodeCamp\freeCodeCamp\api-server\node_modules\mongodb\lib\core\connection\connect.js:294:16)
at Object.onceWrapper (events.js:288:20)
at Socket.emit (events.js:200:13)
at Socket.EventEmitter.emit (domain.js:471:20)
at Socket._onTimeout (net.js:432:8)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7) {
name: ‘MongoNetworkError’,
[Symbol(mongoErrorContextSymbol)]: {}
}]

Followed by an error with Gatsby:

Gatsby error

Error in “C:\Users\shauh\Documents\freeCodeCamp\freeCodeCamp\client\node_modules\gatsby-plugin-manifest\gatsby-node.js”:
Something went wrong installing the “sharp” module

An the Sharp module:

Error: Something went wrong installing the “sharp” module
Cannot find module ‘…/build/Release/sharp.node’
Require stack:

  • C:\Users\shauh\Documents\freeCodeCamp\freeCodeCamp\client\node_modules\sharp \lib\constructor.js

This is what I encounter with npm run clean-and-develop

gatsby

‘gatsby’ is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @freecodecamp/client@1.0.0 clean: gatsby clean
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @freecodecamp/client@1.0.0 clean script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

have you tried in the Gitter room?
it is usually more helpful to ask there than here

Yes, I posted a link to this in the Gitter room. I just did not want to spam the room with a hundred lines of error. :slight_smile:

I personally prefer the forum more than anything else for the async and threaded nature of discussions. It should be fine to post here :slight_smile:

Thanks for the detailed errors. I do not have access to a windows machine to give you the best support, but I can surely help with some approaches:

node-gyp

You probably want: https://github.com/nodejs/node-gyp#on-windows

It is a binary that some of the dependencies of freeCodeCamp depend upon.

Unfortunately the quirky nature of having node-gyp on your system means you may need to compile it for your host: (Windows in your case, macOS - aka Darwin in my case, or Ubuntu - aka debian in someone else’s). The compilation is quite automatic, but requires even more dependencies for the compiler to be able to build node-gyp. In my case its tooling that Xcode uses, in your case its Visual Studio, etc.

I know what you are thinking freeCodeCamp (JS) --> Dependencies --> node-gyp --> more native dependencies. Yup, that’s just how it is. You need C++ compiler tooling for no obvious reason but that’s how it is. :slightly_frowning_face:

On macOS I would get my native compiler tools using Xcode’s binaries. For windows you would need:

npm install --global --production windows-build-tools

As for the gatsby-error:

It is because sharp is one of the modules that is dependant on node-gyp.

As for the final error:

Its a side effect. When you run npm run clean-and-develop it purged your node_modules and since the installation did not go thru gatsby is not available. Basically the command broke midway.

You should do a npm ci which will only install all the dependencies, and proceed from there. It helps to understand what these commands do under the hood. We are around to explain of course.

I have no idea if this is related to your problem, but on my current work project several of us on Windows machines were having packaging failures due to node-gyp. It actually turned out to be a failure to properly install all the Python dependencies when we installed Node. We have had a 100% success rate so far by uninstalling and re-installing Node. Might be worth a shot. (We also see messages about tools for Visual Studio during the Node install process, even though none of us have Visual Studio).

Thanks for the additional inputs Ariel.

Yes, even we broke all the builds a day before when Node.js released a new LTS version 12.16.3 --> 12.17.0

We had to resolve by bumping babel. So it is totally possible the recent release could be a cause.

re-installing node is worth a try.

just a default suggestion, as questions like this on the forum rarely get answers

I agree and empathise with this.

We should probably change that. I will subscribe to the category and see if I can help as much as I can. :slightly_smiling_face:

1 Like

Thank you, for this help.

I have had such confusing experiences with setting up locally. One day, it works without a hitch, the next (even before any rebase), it can no longer work.

I have been all over the fsevents and node-gyp github issues threads, and come across multiple work arounds. Seeing as some of our setup does not depend on much of node-gyp, I have used the bare minimum to build node-gyp, and just get past the errors.

Now, I am encountering issues with MongoDB.
@raisedadead, where would I find the call to connect to the MongoClient to pass this option:

pass option { useUnifiedTopology: true } to the MongoClient constructor.

Summary

Connection fails: MongoNetworkError: failed to connect to server [localhost:27017] on first connect [MongoNetworkError: connection timed out

That’s a recommendation not a requirement. It is part of the configuration of the connect-mongo middleware we use to manage sessions.

We haven’t updated it yet. It should not affect your local setup.

The failure is coming from somewhere else. What happens when you setup the repo to the teeth using the guide.

Usually, I encounter the same sharp module not found as the most frequent issue.

It has just been today that the node-gyp has given me these specific issues (as far as I recall).

I understand your frustration. It is a complex codebase and we are working on trying to make it simpler. The easiest way is to use GitPod.

Windows is still a pain, primarily because none of the dev-team is actively developing on windows to see the gotchas and accommodate for it. :slightly_frowning_face:

We should work on this, but we have only limited time.

Thanks for the information.

I will see if I can find the root cause. What I do know that sharp (used for some image processing / compressions stuff) uses node-gyp under the hood.

Did you try installing latest Node LTS?

Please do not worry about spending more time on many of my specific issues. Every now and again, I look to see if there have been any changes on the WSL front, and I am going to get a second laptop up and running with Linux to see the success of that.

Thank you, for all your time.

Thanks for your generosity.

We do want to be able to make it work for users on Windows. :slightly_smiling_face: Its a significant no. of contributors using Windows.

I am updating now. Was on v12.4. So, v12.17.0 might make a difference. Or, as Ariel said, perhaps reinstalling will just help.

I’ve been able to set up VS Code with WSL on a couple computers to compile C++ code in a linux environment on a Windows computer, but I haven’t tried it with a Node application. I’m not sure how well the WSL allows you to install Node separately on the subsystem. I know that there are some limitations that prevent you from basically using it as a Linux VM. If you can install all the dependencies on the subsystem though, I’ve actually found the WSL to finally be sufficiently user-friendly that it’s been a really good compromise. The hard part is finding the right tutorials to get everything set up because…they’re hit and miss.

Did you have any issues with using Git on the WSL?

Because, every time I solve one issue, I encounter another, and unable to perform git clone, git fetch without getting some version of:

error: RPC failed; curl 56 GnuTLS recv error (-9): A TLS packet with unexpected length was received. fatal: the remote end hung up unexpectedly fatal: early EOF fatal: index-pack failed

Nope.