TypeError : "ObjectId " is not a function

Hi there ^^
so I did everything as mentioned here : Contribution Guidelines | freeCodeCamp.org
and everything worked completely fine. However when i try :

npm run seed

> @freecodecamp/freecodecamp@0.0.1 seed /home/xbebex/mine/freeCodeCamp
> cross-env DEBUG=fcc:* node ./tools/scripts/seed/seedAuthUser

/home/xbebex/mine/freeCodeCamp/tools/scripts/seed/certifiedUserData.js:6
  _id: ObjectId('5fa2db00a25c1c1fa49ce067'),
       ^

TypeError: ObjectId is not a function
    at Object.<anonymous> (/home/xbebex/mine/freeCodeCamp/tools/scripts/seed/certifiedUserData.js:6:8)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
    at Module.load (internal/modules/cjs/loader.js:937:32)
    at Function.Module._load (internal/modules/cjs/loader.js:778:12)
    at Module.require (internal/modules/cjs/loader.js:961:19)
    at require (internal/modules/cjs/helpers.js:92:18)
    at Object.<anonymous> (/home/xbebex/mine/freeCodeCamp/tools/scripts/seed/seedAuthUser.js:6:28)
    at Module._compile (internal/modules/cjs/loader.js:1072:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1101:10)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @freecodecamp/freecodecamp@0.0.1 seed: `cross-env DEBUG=fcc:* node ./tools/scripts/seed/seedAuthUser`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the @freecodecamp/freecodecamp@0.0.1 seed 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!     /root/.npm/_logs/2021-08-22T15_15_59_109Z-debug.log

and here is the log file :

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/root/.nvm/versions/node/v14.17.5/bin/node',
1 verbose cli   '/root/.nvm/versions/node/v14.17.5/bin/npm',
1 verbose cli   'run',
1 verbose cli   'seed'
1 verbose cli ]
2 info using npm@6.14.14
3 info using node@v14.17.5
4 verbose run-script [ 'preseed', 'seed', 'postseed' ]
5 info lifecycle @freecodecamp/freecodecamp@0.0.1~preseed: @freecodecamp/freecodecamp@0.0.1
6 info lifecycle @freecodecamp/freecodecamp@0.0.1~seed: @freecodecamp/freecodecamp@0.0.1
7 verbose lifecycle @freecodecamp/freecodecamp@0.0.1~seed: unsafe-perm in lifecycle true
8 verbose lifecycle @freecodecamp/freecodecamp@0.0.1~seed: PATH: /root/.nvm/versions/node/v14.17.5/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/xbebex/mine/freeCodeCamp/node_modules/.bin:/root/.nvm/versions/node/v14.17.5/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
9 verbose lifecycle @freecodecamp/freecodecamp@0.0.1~seed: CWD: /home/xbebex/mine/freeCodeCamp
10 silly lifecycle @freecodecamp/freecodecamp@0.0.1~seed: Args: [
10 silly lifecycle   '-c',
10 silly lifecycle   'cross-env DEBUG=fcc:* node ./tools/scripts/seed/seedAuthUser'
10 silly lifecycle ]
11 silly lifecycle @freecodecamp/freecodecamp@0.0.1~seed: Returned: code: 1  signal: null
12 info lifecycle @freecodecamp/freecodecamp@0.0.1~seed: Failed to exec seed script
13 verbose stack Error: @freecodecamp/freecodecamp@0.0.1 seed: `cross-env DEBUG=fcc:* node ./tools/scripts/seed/seedAuthUser`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/root/.nvm/versions/node/v14.17.5/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:400:28)
13 verbose stack     at ChildProcess.<anonymous> (/root/.nvm/versions/node/v14.17.5/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:400:28)
13 verbose stack     at maybeClose (internal/child_process.js:1055:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid @freecodecamp/freecodecamp@0.0.1
15 verbose cwd /home/xbebex/mine/freeCodeCamp
16 verbose Linux 4.9.0-4-amd64
17 verbose argv "/root/.nvm/versions/node/v14.17.5/bin/node" "/root/.nvm/versions/node/v14.17.5/bin/npm" "run" "seed"
18 verbose node v14.17.5
19 verbose npm  v6.14.14
20 error code ELIFECYCLE
21 error errno 1
22 error @freecodecamp/freecodecamp@0.0.1 seed: `cross-env DEBUG=fcc:* node ./tools/scripts/seed/seedAuthUser`
22 error Exit status 1
23 error Failed at the @freecodecamp/freecodecamp@0.0.1 seed script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Thanks for helping me <3

Welcome there,

It sounds like you did not run npm ci in the root of the workspace. mongodb is the name of the NPM package used in the api-server.

Hope this helps

1 Like

Thnx for ur reply <3 nah i’m pretty sure I did :((

I’m honestly not sure what you meant but here is what i did to get rid of that error :
I installed mongodb module in node_modules directory using npm install mongodb , but I’m not sure it is the right thing to do .
I’m so not familiar with JavaScript so could you please tell me what is this api-sever ? :((

You should not do this, as it is likely to install the latest version of mongodb which is not necessarily the version freeCodeCamp uses.

The api-server is one of the directories in the freeCodeCamp repository. Within it, is the code for the API/server. You can find the package.json file, which is installing the expected version of mongodb.

Hope this clarifies.

If you are still struggling, I suggest you use the GitPod route mentioned in the Contributors Docs, as it handles the installation for you, and works through the browser.

1 Like

Thank you so much for replying, your help is much appreciated <3 , I will try your suggestions and hopefully that will fix the problem .

Soo , Although I cant specify a straightforward solution to the any of the errors I encountered lol , I’m very thankful for the guy who replied to me as it helped me troubleshooting and understanding what is it about.
So as a solution I would suggest to anyone who ran through errors while setting up freecodecamp locally to make sure that they followed the steps of the official contributors docs right and to care for details especially that most of ppl trying to get it work are mostly new to programming like me, so my suggestion is to troubleshoot whatever comes and learn as much as possible throughout the way and good luck <3

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.