How to clone and setup the Free Code Camp website on a Windows pc

How to clone and setup the Free Code Camp website on a Windows pc
0

#1

In this guide, we’ll be setting up the freeCodeCamp local development environment. Setting up the development environment on a Windows PC is easy, although it will likely give a lot of errors first in the process. The important part is to correct these errors.

Prerequisites

Prerequisite Version
MongoDB Community Server ~ ^3
MailHog ~ ^1
Git Bash ~ ^2
Node.js ~ ^8.9.3
npm (comes with Node.js) ~ ^5

Updating to the latest releases is recommended.

Run the following commands one by one to validate the versions of the prerequisites installed:

node -v
npm -v
mongo --version

Installation

Create the default folder for Mongo to store databases in: C:\data\db.

If you want to spare the time in explorer finding Mongo when it has to be started create a .cmd file on your desktop and write the path to Mongo. Probably "%programfiles%\MongoDB\Server\3.0\bin\mongod.exe". Replace 3.0 with the version you installed.

The following commands all have to be executed in Git Bash

  1. Open Git Bash as an Admin and type git config --system core.longpaths true this will make sure that long filenames in the project will be available.
  2. Follow the instructions here freeCodeCamp on Github and clone the project.
  3. Make sure you’re in the directory you cloned with GitHub (by default, this is freecodecamp).
  4. Run npm install
  5. Run cp sample.env .env
  6. Start Mongo and run npm run only-once. You should now see a lot of activity in the window where you started Mongo.
  7. Run npm run develop. After a little while, your local version of freeCodeCamp should be running. You can visit it in your browser at http://localhost:3000

Congrats, you’re done! If you run into any issues while setting up your local version of freeCodeCamp, feel free to reach out to our Contributors chatroom.


Using freeCodeCamp offline?
After cloning freecodecamp, npm run only-once doesn't work
Copy command in Git Bash
#2

Hi,
I see problems when running through these steps.
When node seed is run it fails with following error.

$ node seed
Error: Cannot find module '…/rev-manifest’
at Function.Module._resolveFilename (module.js:470:15)
at Function.Module._load (module.js:418:25)
at Function._load (/home/manish/FreeCodeCamp/FreeCodeCamp/node_modules/pmx/lib/transaction.js:62:21)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/home/manish/FreeCodeCamp/FreeCodeCamp/server/middlewares/jade-helpers.js:1:1)
at Module._compile (module.js:571:32)
at loader (/home/manish/FreeCodeCamp/FreeCodeCamp/node_modules/babel-register/lib/node.js:144:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/manish/FreeCodeCamp/FreeCodeCamp/node_modules/babel-register/lib/node.js:154:7)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Function._load (/home/manish/FreeCodeCamp/FreeCodeCamp/node_modules/pmx/lib/transaction.js:62:21)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at /home/manish/FreeCodeCamp/FreeCodeCamp/node_modules/loopback-boot/lib/executor.js:343:19

I tried installing rev-manifest module but it did not help.

Thanks,
Manish


#3

$ touch server/rev-manifest.json
$ echo ‘{}’ >> server/rev-manifest.json

were the steps needed to be performed.

-Manish


#4

Thanks for the info Manish! I updated the guide to include the script that does that for you.


#5

I had to run the npm commands in the free code camp directory. Is that obvious? (I’ve never used node.js before. It took me a while to figure that out.)


#6

Thanks - I’ll update this to clarify this.


#7

Does it matter which 2.7 Python is installed - the 32 bit or 64 bit ? Usually install software that matches the OS, but read that 32 bit python is preferred regardless of your OS because 64 bit version might not work with certain python libraries. Wanted to check if it mattered for the FCC build.


#8

how can i Set up your private environment variables (API Keys)?


#9

When I run this command 'npm run only-once. ’ i get the following error: “Error: Connection strategy not found”


#10

Hi all! I have updated the wiki to resolve the problems you had.

@seahik I’m not sure. I haven’t heard about any problems with the wrong version of Python.

@dhrey112 You should only have to copy the sample.env file to a new .env file for that. I have updated the wiki to avoid confusion about this in the future.

@netstudenton It sounds like you missed the step of copying the sample.env file to a new .env file, or it went wrong. Previously, it was step 5 of the first list. I have now made it step 3 of the second list. Hopefully the change makes it easier to follow along.


#11

Mine says “[thread1] waiting for connections on port 27017” - it does not allow commands to be typed.at this point.

Edit: perhaps you meant “start a new shell, change to the directory where the freeCodeCamp repo is located and run npm run only-once.” But when I did that, it did not cause any additional output in the window where I started mongod. I’m not sure if this is the expected output:

C:\Dev\freeCodeCamp>npm run only-once

> [email protected] only-once C:\Dev\freeCodeCamp
> npm run create-rev && echo '

seeding database

' && node seed && echo '

Seeding Completed

'


> [email protected] create-rev C:\Dev\freeCodeCamp
> node -e "var fs = require('fs'); fs.access('./server/rev-manifest.json', function(err) { if (err) { c
onsole.log('\n\ncreating manifest\n\n'); return fs.writeFileSync('server/rev-manifest.json', '{}'); } c
onsole.log('\n\nrev-manifest present\n\n'); });"



creating manifest


'

#12

Well, the site seemed to start locally, but how to log in? I decided to try the “Sign Up” link to create an account. When I tried to sign up, {} appeared in the browser window and the site crashed:

200 GET 367.425 ms - /en/vendor-main.js
loopback deprecated loopback#context middleware is deprecated. See https://docs.strongloop.com/display/
APIC/Using%20current%20context for more details. node_modules\loopback\server\middleware\rest.js:60:32
  fcc:user:remote checking existence +24s
  fcc:user:remote where { email: '[email protected]' } +1ms
  fcc:user:remote user created, sending email +86ms
200 POST 380.793 ms - /api/users
Error: Callback was already called.
    at C:\Dev\freeCodeCamp\node_modules\async\dist\async.js:903:32
    at C:\Dev\freeCodeCamp\node_modules\async\dist\async.js:3835:13
    at interceptInvocationErrors (C:\Dev\freeCodeCamp\node_modules\strong-remoting\lib\remote-objects.js:690:22)
    at C:\Dev\freeCodeCamp\node_modules\loopback-phase\node_modules\async\lib\async.js:154:25
    at C:\Dev\freeCodeCamp\node_modules\loopback-phase\node_modules\async\lib\async.js:154:25
    at C:\Dev\freeCodeCamp\node_modules\loopback-phase\node_modules\async\lib\async.js:154:25
    at C:\Dev\freeCodeCamp\node_modules\strong-remoting\lib\remote-objects.js:656:7
    at C:\Dev\freeCodeCamp\node_modules\strong-remoting\lib\http-context.js:397:7
    at callback (C:\Dev\freeCodeCamp\node_modules\strong-remoting\lib\shared-method.js:253:5)
    at C:\Dev\freeCodeCamp\node_modules\loopback-datasource-juggler\lib\dao.js:381:19
    at doNotify (C:\Dev\freeCodeCamp\node_modules\loopback-datasource-juggler\lib\observer.js:99:49)
    at C:\Dev\freeCodeCamp\node_modules\loopback-datasource-juggler\lib\observer.js:112:23
    at C:\Dev\freeCodeCamp\node_modules\loopback-datasource-juggler\node_modules\async\lib\async.js:189:25
    at invalidateOtherTokens (C:\Dev\freeCodeCamp\node_modules\loopback\common\models\user.js:920:38)
    at notifySingleObserver (C:\Dev\freeCodeCamp\node_modules\loopback-datasource-juggler\lib\observer.js:104:22)
    at iterate (C:\Dev\freeCodeCamp\node_modules\loopback-datasource-juggler\node_modules\async\lib\async.js:181:13)
    at Object.async.eachSeries (C:\Dev\freeCodeCamp\node_modules\loopback-datasource-juggler\node_modules\async\lib\async.js:197:9)
    at doNotify (C:\Dev\freeCodeCamp\node_modules\loopback-datasource-juggler\lib\observer.js:101:11)
    at doNotify (C:\Dev\freeCodeCamp\node_modules\loopback-datasource-juggler\lib\observer.js:99:49)
    at doNotify (C:\Dev\freeCodeCamp\node_modules\loopback-datasource-juggler\lib\observer.js:99:49)
    at doNotify (C:\Dev\freeCodeCamp\node_modules\loopback-datasource-juggler\lib\observer.js:99:49)
    at Function.ObserverMixin._notifyBaseObservers (C:\Dev\freeCodeCamp\node_modules\loopback-datasource-juggler\lib\observer.js:122:5)
[06:09:00] [nodemon] app crashed - waiting for file changes before starting...

#13

I get the following code when I ran gulp on the freecodescamp folder

/home/kofi/Desktop/freeCodeCamp-staging/gulpfile.js:171
function errorHandler(…args) {
^^^

SyntaxError: Unexpected token …
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions…js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Liftoff.handleArguments (/usr/local/lib/node_modules/gulp/bin/gulp.js:116:3)
at Liftoff. (/usr/local/lib/node_modules/gulp/node_modules/liftoff/index.js:198:16)
at module.exports (/usr/local/lib/node_modules/gulp/node_modules/flagged-respawn/index.js:17:3)


#14

Hi @kofimokome!
I believe I replied to you on Gitter as well. This sounds like a problem with an outdated version of Node.js
freeCodeCamp requires at least version 6. You can check which version you’re running with the following command: node -v
You can follow the link in the article at the top and run the installer to update. You might need to restart after installation to get things to work.


#15

Hi,

Please update path to have quotes around them in step 5, where we are creating a shortcut to mongodb executable on Windows.

The %programfiles% environment variable returns path without escaping spaces and this throws an error in cmd. “%programfiles%\MongoDB\Server\3.0\bin\mongod.exe” worked for me. Also please hint to substitute installed mongodb version in place of 3.0.

Thanks,
Narveer


#16

@narveersingh That’s a good idea! I updated the wiki, can you check if it’s OK this way?


#17

I get this error everytime i type the commands in cmd

npm install gulp -g
npm ERR! Windows_NT 10.0.10240
npm ERR! argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “install” “gulp” "-g"
npm ERR! node v7.9.0
npm ERR! npm v4.2.0
npm ERR! file C:\Users\EMMANUEL\AppData\Roaming\npm-cache\deprecated\0.0.1\package\package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! Unexpected token ‘\u0000’ at 1:1
npm ERR!
npm ERR! ^
npm ERR! File: C:\Users\EMMANUEL\AppData\Roaming\npm-cache\deprecated\0.0.1\package\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\EMMANUEL\AppData\Roaming\npm-cache_logs\2017-07-09T01_04_48_781Z-debug.log

C:\WINDOWS\system32>npm install node-gyp -g
npm ERR! Windows_NT 10.0.10240
npm ERR! argv “C:\Program Files\nodejs\node.exe” “C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js” “install” “node-gyp” "-g"
npm ERR! node v7.9.0
npm ERR! npm v4.2.0
npm ERR! file C:\Users\EMMANUEL\AppData\Roaming\npm-cache\mkdirp\0.5.1\package\package.json
npm ERR! code EJSONPARSE

npm ERR! Failed to parse json
npm ERR! Unexpected token ‘\u0000’ at 1:1
npm ERR!
npm ERR! ^
npm ERR! File: C:\Users\EMMANUEL\AppData\Roaming\npm-cache\mkdirp\0.5.1\package\package.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! Please include the following file with any support request:
npm ERR! C:\Users\EMMANUEL\AppData\Roaming\npm-cache_logs\2017-07-09T01_05_17_527Z-debug.log


#18

Hi @MORONFOLUWA!
I’ve never seen that error before. A google search suggests that this happens because the npm cache got corrupted. It should be fixed by running npm cache clean
Can you try that and let me know if it works?


#19

I got it working! Thanks for this guide.
Here is my setup:

Windows 10
Python 3.6.0 but I also have Python 2.7 but 3.6 is the one on my PATH
Node 6.10.0
npm 3.10.10
MongoDB 3.2.10

On step 5 I got an error, but this answer helped me resolved it by changing the port of mongo, and on the .env file. And also on step 3 its copy not cp as the guide is for windows pc .

Also I’m getting this error, after sign up, but then I am able to sign in with the account I just signed. Anyway I tried it and I think it’s working fine.


Local Instance of FCC
#20

Thankyou! I found this guide very helpful