Issues with local setup trying to seed the DB

Issues with local setup trying to seed the DB
0

I’m trying to get everything set up locally and followed the instructions exactly. I just installed MongoDB using Homebrew (following the Mongo doc instructions). I opened a new terminal and ran mongod, and in the other terminal, tried running npm run seed. It’s failing. This is the output I get:


internal/modules/cjs/loader.js:583
    throw err;
    ^

Error: Cannot find module 'mongodb'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Module.require (internal/modules/cjs/loader.js:637:17)
    at require (internal/modules/cjs/helpers.js:22:18)
    at Object.<anonymous> (/Users/MYUSERNAME/Desktop/fcc-a11y/freeCodeCamp/tools/scripts/seed/seedChallenges.js:4:21)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @freecodecamp/[email protected] seed: `cross-env DEBUG=fcc:* node ./tools/scripts/seed/seedChallenges`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @freecodecamp/[email protected] 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:

Any help would be appreciated!

Have you ran npm ci yet?

Also, are you doing the Docker Build installation or the Local Build installation?

Yes, I did! I’ve followed the directions in order. Everything was fine through running mongod in another terminal, but once I ran npm run seed in the original terminal, I got the error above and have not been able to move forward.

I am doing the local build, not Docker.

When you ran the npm ci, did it create a node-modules directory in the local repo and are you running npm run seed from root directory of the local repo or from some other directory?

Can you take a screenshot of the folder containing the repo where it would show all of the files?

Yes, and I am running, or trying to run npm run seed from the project’s root directory. Here is a screenshot of the folder:

Can you take a look in api-server/node_modules/ and see if a) anything’s there and b) mongodb is there? It sounds like the api server’s packages are not getting installed. Something that npm ci should have taken care of.

If that package isn’t there, please run npm run bootstrap from the root dir and paste in the output. It should be something like this:
image

This does seem to be the problem. The folder doesn’t exist.

ls api-server/node_modules/
ls: api-server/node_modules/: No such file or directory

When I run npm run bootstrap from the projects root dir, it fails. I get the following output:

> @freecodecamp/[email protected] prebootstrap /Users/MYUSERNAME//Desktop/fcc-a11y/freeCodeCamp
> npm run ensure-env


> @freecodecamp/[email protected] ensure-env /Users/MYUSERNAME//Desktop/fcc-a11y/freeCodeCamp
> cross-env DEBUG=fcc:* node ./tools/scripts/ensure-env.js

  fcc:tools:ensure-env creating pathMigration +0ms
  fcc:tools:ensure-env _redirects written +4ms

> @freecodecamp/[email protected] bootstrap /Users/MYUSERNAME//Desktop/fcc-a11y/freeCodeCamp
> lerna bootstrap && lerna run build --scope @freecodecamp/curriculum

lerna notice cli v3.4.0
lerna info versioning independent
lerna info Bootstrapping 5 packages
lerna info Installing external dependencies
lerna ERR! npm install exited 1 in '@freecodecamp/client'
lerna ERR! npm install stderr:
npm ERR! code ETARGET
npm ERR! notarget No matching version found for [email protected]
npm ERR! notarget In most cases you or one of your dependencies are requesting
npm ERR! notarget a package version that doesn't exist.
npm ERR! notarget
npm ERR! notarget It was specified as a dependency of 'client'
npm ERR! notarget

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/MYUSERNAME//.npm/_logs/2019-10-05T17_28_06_993Z-debug.log

lerna ERR! npm install exited 1 in '@freecodecamp/client'
lerna WARN complete Waiting for 3 child processes to exit. CTRL-C to exit immediately.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @freecodecamp/[email protected] bootstrap: `lerna bootstrap && lerna run build --scope @freecodecamp/curriculum`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @freecodecamp/[email protected] bootstrap 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!     /Users/MYUSERNAME/.npm/_logs/2019-10-05T17_28_07_083Z-debug.log

From within the root of the repo directoy can you run npm ci again and post the results. I want to see if you are getting any errors showing during install.

Just ran it again and no errors:

npm ci
npm WARN prepare removing existing node_modules/ before installation

> [email protected] install /Users/MYUSERNAME/Desktop/fcc-a11y/freeCodeCamp/node_modules/fsevents
> node install

node-pre-gyp info it worked if it ends with ok
node-pre-gyp info using node-pre-g[email protected]
node-pre-gyp info using [email protected] | darwin | x64
[fsevents] Success: "/Users/Cosmia/Desktop/fcc-a11y/freeCodeCamp/node_modules/fsevents/lib/binding/Release/node-v64-darwin-x64/fse.node" already installed
Pass --update-binary to reinstall or --build-from-source to recompile
node-pre-gyp info ok
added 1014 packages in 11.267s

Then I tried running mongod in another terminal and npm run seed again and still got all of the same errors as before.

Have you pulled down the latest version of master? It looks like an old commit. I recommend pulling down master and then running:

npm ci
npm run clean
npm ci
npm run seed
npm run develop

npm ci needs to be run first to install things that npm run clean needs.

1 Like

Thank you! That fixed the original issue. Now I am able to seed the db, but now when I run npm run develop, all goes well until this error:

success run static queries - 0.218 s — 1/1 5.15 queries/second
success run page queries - 9.851 s — 1523/1523 155.00 queries/second

 ERROR

There was an error compiling the html.js component for the development server.

See our docs page on debugging HTML builds for help https://gatsby.dev/debug-html AlgoliaSearchError: Please provide an application ID. Usage: algoliasearch(applicationID, apiKey, opts)


  48 |
  49 |   if (opts._allowEmptyCredentials !== true && !applicationID) {
> 50 |     throw new errors.AlgoliaSearchError('Please provide an application ID. ' + usage);
     | ^
  51 |   }
  52 |
  53 |   if (opts._allowEmptyCredentials !== true && !apiKey) {


  WebpackError: AlgoliaSearchError: Please provide an application ID. Usage: alg  oliasearch(applicationID, apiKey, opts)

  - AlgoliaSearchCore.js:50 AlgoliaSearchNodeJS.AlgoliaSearchCore
    node_modules/algoliasearch/src/AlgoliaSearchCore.js:50:1

  - AlgoliaSearch.js:11 AlgoliaSearchNodeJS.AlgoliaSearch
    node_modules/algoliasearch/src/AlgoliaSearch.js:11:1

  - AlgoliaSearchServer.js:17 AlgoliaSearchNodeJS.AlgoliaSearchServer
    node_modules/algoliasearch/src/server/builds/AlgoliaSearchServer.js:17:1

  - node.js:83 new AlgoliaSearchNodeJS
    node_modules/algoliasearch/src/server/builds/node.js:83:1

  - node.js:68 algoliasearch
    node_modules/algoliasearch/src/server/builds/node.js:68:1

  - WithInstantSearch.js:23 Module../src/components/search/WithInstantSearch.js
    src/components/search/WithInstantSearch.js:23:36

  - index.js:1 Module../src/components/layouts/index.js
    src/components/layouts/index.js:1:1

  - layoutSelector.js:1 Module../utils/gatsby/layoutSelector.js
    utils/gatsby/layoutSelector.js:1:1

  - gatsby-ssr.js:1 Module../gatsby-ssr.js
    gatsby-ssr.js:1:1

  - index.js:71 emit
    node_modules/@babel/code-frame/lib/index.js:71:1



npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @freecodecamp/[email protected] develop: `node --inspect=0.0.0.0:9228 node_modules/gatsby-cli develop`
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!     /Users/MyUserName/.npm/_logs/2019-10-05T20_19_07_068Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @freecodecamp/[email protected] develop:client: `cd ./client && npm run develop`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @freecodecamp/[email protected] develop:client 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!     /Users/MyUserName/.npm/_logs/2019-10-05T20_19_07_144Z-debug.log
ERROR: "develop:client" exited with 1.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @freecodecamp/[email protected] develop: `npm-run-all ensure-env -p develop:*`
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!     /Users/MyUserName/.npm/_logs/2019-10-05T20_19_07_292Z-debug.log

The latest error makes me think your .env is not using the latest version of sample.env. Can you post your .sample.env contents here?

Yea, I just got that error - there’s a recent addition to the sample.env file - Adding ALGOLIA_API_KEY=123abc to it should fix it.