Simran Makhija
Simran Makhija

Reputation: 1

Gatsby - Error: Cannot find module '..\node_modules\gatsby\dist\utils\babel-loader.js'

When running gatsby develop, right after gatsby new with configurations provided in the tutorial here - https://www.gatsbyjs.com/docs/tutorial/part-1/, I am getting this error

Module build failed (from ../../my-first-gatsby-sitenode_modules/gatsby/dist/utils/babel-loader.js): Error: Cannot find module '..\my-first-gatsby-site\node_modules\gatsby\dist\utils\babel-loader.js'

Solutions I have tried:

  1. Delete node_modules, package-lock => npm install / yarn.
  2. Run npm install in node_modules/gatsby.
  3. npm -g --save babel-loader.

Please help if you have come across the error and been able to resolve it. TIA.

Upvotes: 0

Views: 5112

Answers (1)

Ferran Buireu
Ferran Buireu

Reputation: 29320

Run npm install in node_modules/gatsby.

npm install must be run in the root of your project, not inside node_modules.

Delete node_modules, package-lock => npm install / yarn.

You should only choose npm or yarn, not both.

Try the following:

  • Run the following: npm install --save gatsby-cli
  • If you have many audit warnings before the previous command, run: npm audit fix (in the root of your project).
  • Remove your node_modules and reinstall the dependencies in the root of your project by: npm install

Upvotes: 3

Related Questions