question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Cannot find module /node_modules/gatsby-cli/scripts/postinstall.js

See original GitHub issue

As others have described, I am getting an error when attempting to install the gatsby-cli. Is there a solution to this? Environment is Ubuntu 16.04, Nodejs is 12.16.1.

The error:

Error: Cannot find module '/root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry/src/postinstall.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at Function.Module._load (internal/modules/cjs/loader.js:864:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

> gatsby-cli@2.11.3 postinstall /root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli
> node scripts/postinstall.js

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

Error: Cannot find module '/root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli/scripts/postinstall.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
    at Function.Module._load (internal/modules/cjs/loader.js:864:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-cli@2.11.3 postinstall: `node scripts/postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-cli@2.11.3 postinstall 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/2020-03-30T01_47_08_399Z-debug.log
root@ubuntu-s-1vcpu-1gb-sfo2-01:~/gatsby# npm install -g gatsby-cli@2.7.2

Steps to reproduce

All I did was follow the tutorial here and ran this (but as root, not user) npm install -g gatsby-cli

Expected result

Need to install gatsby-cli properly.

Actual result

Errors

Environment

System: OS: Linux 4.4 Ubuntu 16.04.6 LTS (Xenial Xerus) CPU: (1) x64 Intel® Xeon® Gold 6140 CPU @ 2.30GHz Shell: 4.3.48 - /bin/bash Binaries: Node: 12.16.1 - ~/.nvm/versions/node/v12.16.1/bin/node npm: 6.13.4 - ~/.nvm/versions/node/v12.16.1/bin/npm Languages: Python: 2.7.12 - /usr/bin/python Browsers: Firefox: 74.0 npmGlobalPackages: gatsby-cli: 2.7.2

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:13 (7 by maintainers)

github_iconTop GitHub Comments

3reactions
LekoArtscommented, Oct 5, 2020

Hi!

Since we didn’t receive an answer for 7 business days or more about the ask of a reproduction I’m going to close this now, as we can’t do much to help without a reproduction. If you are able to create a minimal reproduction for this then please do answer here or reopen the issue. Thanks!

1reaction
jamocommented, Nov 15, 2020

Perfect, thanks for helping out!

And here is PR https://github.com/gatsbyjs/gatsby/pull/28067 with the changes

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I resolve "Cannot find module" error using Node.js?
Using npm install installs the module into the current directory only (in a subdirectory called node_modules ). Is app.js located under ...
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
To fix the error, you need to install the package that is absent in your project directory – npm install package-name or yarn...
Read more >
Fix Global Installs Not Working | "Cannot find module" error FIX
Getting " Cannot find module " after installing something globally (with -g)? Well, this video shows you how to fix global package/module ...
Read more >
[Solution] Error: Cannot Find Module "nodemailer" - Courier
This error occurs when you have not installed the nodemailer library in your Node.js application. Solution - Here's How To Resolve It. First,...
Read more >
"Cannot find module" when main file not index.js with ... - GitHub
The script should display Success! , and does do so if mypackage/Lib.js is renamed to mypackage/index.js . What do you see instead? internal/ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found