Freecodecamp: After cloning freecodecamp repo, npm run only-once didn鈥檛 work

Created on 22 Jun 2018  路  17Comments  路  Source: freeCodeCamp/freeCodeCamp

I wanted to clone the FCC repo in order to fix an issue and create a PR.
I followed the installation steps specified here: https://forum.freecodecamp.org/t/how-to-clone-and-setup-the-free-code-camp-website-on-a-windows-pc/19366

The problem

When I ran npm run only-once in git bash, I got the following response:

$ npm run only-once

> [email protected] only-once C:\Users\***\Coding\freeCodeCamp\freeCodeCamp
> npm run prelint-js && echo '/****/' && echo 'Seeding Database' && echo '/****/' && SEEDING=true node seed/index.js && echo '/****/' && echo 'Seeding Completed' && echo '/****/'


> [email protected] prelint-js C:\Users\***\Coding\freeCodeCamp\freeCodeCamp
> npm run ensure-env


> [email protected] ensure-env C:\Users\***\Coding\freeCodeCamp\freeCodeCamp
> node ./config/ensure-env.js



rev-manifest present




pathMigration present


'/****/'
'Seeding Database'
'/****/'
'SEEDING' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] only-once: `npm run prelint-js && echo '/****/' && echo 'Seeding Database' && echo '/****/' && SEEDING=true node seed/index.js && echo '/****/' && echo 'Seeding Completed' && echo '/****/'`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] only-once 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\***\AppData\Roaming\npm-cache\_logs\2018-06-22T11_57_18_601Z-debug.log

How do I go from here?
Is there any way to fix this easily?
If not, how do I remove everything to start again?

System info:

  • Operating System: Windows 10
  • Node.js version: v8.11.1
  • npm version: 5.6.0
  • git version: 2.16.2.windows.1
  • MongoDB Community Server version: v3.6.5 (latest, from today)

Screenshots

Screenshot from git bash:
image

Screenshot from MongoDB:
image

Most helpful comment

Despite having a fix in #17472, this error still persists. I bypassed it by dividing the long npm run prelist-js &&... command into separate steps. Like this:

  1. Run just the npm run prelint-js
  2. Add SEEDING=true into your .env (Don't forget to remove it before running npm run develop)
  3. Run node seed/index.js

All 17 comments

@udidol My wild guess is this has to do with the removal of the curriculum from the repo. This repo now only holds the code for the welcome page and the settings page, I believe. If you would like to work on the curriculum UI, the learn repo is for that. Or if you would like to work on the curriculum content, you should go over the curriculum repo.

@huyenltnguyen I did that. I performed my fix to the lesson in a clone I made of the curriculum repo, but without running FCC locally I can't test my fix... I won't commit a PR without testing it first

I joined the Gitters contributors chatroom and found a solution.
It's not ideal since the npm run only-once command still doesn't work, but it seemed to have done the job.

The solution was to run the command that is first displayed after running npm run only-once:
npm run prelint-js && echo '/****/' && echo 'Seeding Database' && echo '/****/' && SEEDING=true node seed/index.js && echo '/****/' && echo 'Seeding Completed' && echo '/****/'

The database should be seeded successfully after that (you can see feedback of the seeding process in the terminal window where you ran mongoDB and in the terminal window you ran the command.

I currently have a different issue which is apparently a known bug, but that calls for a different issue.

For now that's the only way to pass this issue.
If this issue is solved, could you close it?

Well I'm not sure it worked correctly because now I have a different issue, which seems to be a known bug... After seeding the database, I ran npm run develop. It loaded the FCC welcome screen to localhost:3000, but when I click the "start coding" button or the "sign in" button, it takes me to a weird URL: https://stuff/authorize?response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fauth0%2Fcallback&scope=openid%20email&client_id=stuff

I'm not sure if this has anything to do with the npm run only-once problem. If someone from the core team will decide it is not they can close the issue.

@udidol @Nirajn2311 I'm not able to test it at the moment, and I also haven't kept myself up-to-date with this repo's changes, so I apologize if what I'm going to say is obvious or just nonsense.

Here are my questions:

  • What command line did you run after running npm run only-once that fixed the issue?
  • What is your workflow from editing a seed file to submitting a PR?

I'm genuinely curious because this repo doesn't have a code editor and the seed files were removed too, so I don't see how one could test the seed files in here, unless this repo imports the curriculum package. A few months ago, we could use npm run unpack to read and edit the seed files more easily, but I doubt it would work due to the change in the challenge schema.

The curriculum repo has a npm run test script that you can run to test the changes. I think that would suffice. Also, the reviewers will help you double check your code too. But if you want to test it in the browser, I don't think it's possible at the moment.


The auth issue is a known one and is being fixed. It was reported here https://github.com/freeCodeCamp/freeCodeCamp/issues/17382.


I'm not on the core team, but I think this issue should be kept open, since this is obviously a bug and not many contributors know the workaround. Besides, the contributing guide needs to be reviewed and updated.

@huyenltnguyen The answers for your questions:
A1) copy paste the below code to bypass SEEDING is not recognised as a command error(for now until someone solves the issue)

npm run prelint-js && echo '/****/' && echo 'Seeding Database' && echo '/****/' && SEEDING=true node seed/index.js && echo '/****/' && echo 'Seeding Completed' && echo '/****/'

A2) At the moment I haven't thought much of seeding as I am fixing all typos.

I had the same issue running npm run only-once

Copying the commands and pasting them into the terminal ran the seeding with no issues.

Using Windows, Git Bash and Git Shell

I'm still having problems with this, even using Git Bash, i was using Powershell previously. Will try Git Shell now.

I'm still having problems with this锛宑opy paste the code can not solve my issue.

I am experiencing this exact same issue.

I ran npm run prelint-js && echo '/*/' && echo 'Seeding Database' && echo '//' && SEEDING=true node seed/index.js && echo '//' && echo 'Seeding Completed' && echo '/*/'

which allowed npm run develop to be run, but I get sent to the below link when clicking "Start coding (it's free)"

https://stuff/authorize?response_type=code&redirect_uri=http%3A%2F%2Flocalhost%3A3000%2Fauth%2Fauth0%2Fcallback&scope=openid%20profile%20email&client_id=stuff

I also tried running "node seed". It didn't come back with errors, but after I run "npm run develop" the code runs, and I run into that authorize URL issue again.

I ran the steps at https://github.com/freeCodeCamp/freeCodeCamp/issues/17382#issuecomment-406735385 to get past this issue.

How did you even run this?

npm run prelint-js && echo '//' && echo 'Seeding Database' && echo '//' && SEEDING=true node seed/index.js && echo '//' && echo 'Seeding Completed' && echo '//'

It still has SEEDING = true in it, so your OS will try to run that as a command, which it obviously isnt't. Am i missing something here?

Edit: For some reason (i assume it's due to formatting) the command above won't run in vanilla cmd or Visual Studio Code's built-in terminal. It does work in Git Bash, however.

Despite having a fix in #17472, this error still persists. I bypassed it by dividing the long npm run prelist-js &&... command into separate steps. Like this:

  1. Run just the npm run prelint-js
  2. Add SEEDING=true into your .env (Don't forget to remove it before running npm run develop)
  3. Run node seed/index.js

We have resolved this specific issue with local setup. Please re-clone and make a fresh installation. A few other issues in the setup are still being worked upon. We will post an update in Contributors Chat room when the local is 100% ready.

Thanks

Was this page helpful?
0 / 5 - 0 ratings