Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
doverradio opened this issue Mar 30, 2020 · 13 comments
Closed
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: cli Related to the Gatsby CLI type: bug An issue or pull request relating to a bug in Gatsby

Comments

@doverradio
Copy link

doverradio commented Mar 30, 2020

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(R) Xeon(R) 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

@doverradio doverradio added the type: bug An issue or pull request relating to a bug in Gatsby label Mar 30, 2020
@wonism
Copy link
Contributor

wonism commented Mar 30, 2020

It's weird. I succeed to install it globally (as user).

os: osx 10.15.3
nodejs: 12.16.0
npm: 6.13.7

Would you try to install gatsby-cli as user, not a root?

@madalynrose madalynrose added the topic: cli Related to the Gatsby CLI label Mar 31, 2020
@LekoArts LekoArts added the status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. label Sep 15, 2020
@pvdz
Copy link
Contributor

pvdz commented Sep 22, 2020

This issue hasn't seen any updates or "me toos". I'm inclined to close it without a reproduction or more reports. @doverradio please let us know.

@llgdd
Copy link

llgdd commented Sep 25, 2020

Same error.
Ubuntu 18.04.5 LTS on Windows 10 x86_64
Node v14.4.0
NPM v6.14.5

@LekoArts
Copy link
Contributor

LekoArts commented 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!

@LekoArts LekoArts closed this as completed Oct 5, 2020
@shivayan-bora
Copy link

shivayan-bora commented Nov 15, 2020

I am also facing this exact same issue. Here's the details:

[Shivayan] npm install -g gatsby-cli                                                                          12:56:46
npm WARN deprecated @hapi/joi@15.1.1: joi is leaving the @hapi organization and moving back to 'joi' (https://github.com/sideway/joi/issues/2411)
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/address@2.1.4: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
/root/.nvm/versions/node/v12.16.1/bin/gatsby -> /root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli/cli.js

> core-js@2.6.11 postinstall /root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> gatsby-telemetry@1.4.1 postinstall /root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry
> node src/postinstall.js || true

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

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:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

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

internal/modules/cjs/loader.js:638
    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:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/gatsby-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-cli@2.13.1 postinstall: `node scripts/postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-cli@2.13.1 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-11-15T07_28_32_724Z-debug.log

Ubuntu 18.04.5 LTS on Windows 10 x86_64
Node Version: v12.16.1
NPM Version: 6.14.8

@jamo
Copy link
Contributor

jamo commented Nov 15, 2020

I'm unable to reproduce this on fresh Ubuntu, @shivayan-bora-by for debugging I published a test release, would you mind trying to npm i -g gatsby-cli@2.12.100-telemetry-test2.521+c61c129097 and share the output/whether it worked.

@shivayan-bora
Copy link

shivayan-bora commented Nov 15, 2020

Hi,

I tried running the command and it didn't work. I am getting the following output.

[Shivayan] npm i -g gatsby-cli@2.12.100-telemetry-test2.521+c61c129097                                        17:08:38
npm WARN deprecated @hapi/joi@15.1.1: joi is leaving the @hapi organization and moving back to 'joi' (https://github.com/sideway/joi/issues/2411)
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/address@2.1.4: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
/root/.nvm/versions/node/v12.16.1/bin/gatsby -> /root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli/cli.js

> core-js@2.6.11 postinstall /root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> gatsby-telemetry@1.3.36-telemetry-test2.526 postinstall /root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry
> node -e "try{require('./lib/postinstall')}catch(e){console.log(e)}" || true

{ Error: Cannot find module './lib/postinstall'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at [eval]:1:5
    at Script.runInThisContext (vm.js:122:20)
    at Object.runInThisContext (vm.js:329:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at evalScript (internal/bootstrap/node.js:590:27) code: 'MODULE_NOT_FOUND' }

> gatsby-cli@2.12.100-telemetry-test2.521 postinstall /root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli
> node -e "try{require('./scripts/postinstall')}catch(e){}" || true

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/gatsby-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ gatsby-cli@2.12.100-telemetry-test2.521
added 598 packages from 529 contributors in 41.832s

@shivayan-bora
Copy link

shivayan-bora commented Nov 15, 2020

I am wondering if the issue might be because of this:

npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.

@jamo
Copy link
Contributor

jamo commented Nov 15, 2020

The new log ending with added 598 packages from 529 contributors in 41.832s makes me think it logged errors but was successful.

@shivayan-bora
Copy link

So gatsby --help is working for me. However, I updated node to the latest LTS version i.e. 14.15.0 and I was still getting the following error:

[Shivayan] npm install -g gatsby-cli                                                                          17:19:11
npm WARN deprecated @hapi/joi@15.1.1: joi is leaving the @hapi organization and moving back to 'joi' (https://github.com/sideway/joi/issues/2411)
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/address@2.1.4: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
/root/.nvm/versions/node/v14.15.0/bin/gatsby -> /root/.nvm/versions/node/v14.15.0/lib/node_modules/gatsby-cli/cli.js

> core-js@2.6.11 postinstall /root/.nvm/versions/node/v14.15.0/lib/node_modules/gatsby-cli/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> gatsby-telemetry@1.4.1 postinstall /root/.nvm/versions/node/v14.15.0/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry
> node src/postinstall.js || true

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

Error: Cannot find module '/root/.nvm/versions/node/v14.15.0/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry/src/postinstall.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

> gatsby-cli@2.13.1 postinstall /root/.nvm/versions/node/v14.15.0/lib/node_modules/gatsby-cli
> node scripts/postinstall.js

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

Error: Cannot find module '/root/.nvm/versions/node/v14.15.0/lib/node_modules/gatsby-cli/scripts/postinstall.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/gatsby-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-cli@2.13.1 postinstall: `node scripts/postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-cli@2.13.1 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-11-15T11_50_24_791Z-debug.log

I have attached the debug logs as well. Do you think the issue might be with gatsby-telemetry only? I ran the command you provided, and it gave me the following output:

[Shivayan] npm i -g gatsby-cli@2.12.100-telemetry-test2.521+c61c129097                                        17:21:52
npm WARN deprecated @hapi/joi@15.1.1: joi is leaving the @hapi organization and moving back to 'joi' (https://github.com/sideway/joi/issues/2411)
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/address@2.1.4: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
/root/.nvm/versions/node/v14.15.0/bin/gatsby -> /root/.nvm/versions/node/v14.15.0/lib/node_modules/gatsby-cli/cli.js

> core-js@2.6.11 postinstall /root/.nvm/versions/node/v14.15.0/lib/node_modules/gatsby-cli/node_modules/core-js
> node -e "try{require('./postinstall')}catch(e){}"


> gatsby-telemetry@1.3.36-telemetry-test2.526 postinstall /root/.nvm/versions/node/v14.15.0/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry
> node -e "try{require('./lib/postinstall')}catch(e){console.log(e)}" || true

{ Error: Cannot find module './lib/postinstall'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at [eval]:1:5
    at Script.runInThisContext (vm.js:122:20)
    at Object.runInThisContext (vm.js:329:38)
    at Object.<anonymous> ([eval]-wrapper:6:22)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at evalScript (internal/bootstrap/node.js:590:27) code: 'MODULE_NOT_FOUND' }

> gatsby-cli@2.12.100-telemetry-test2.521 postinstall /root/.nvm/versions/node/v14.15.0/lib/node_modules/gatsby-cli
> node -e "try{require('./scripts/postinstall')}catch(e){}" || true

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/gatsby-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ gatsby-cli@2.12.100-telemetry-test2.521
added 598 packages from 529 contributors in 38.568s

2020-11-15T11_50_24_791Z-debug.log

@jamo
Copy link
Contributor

jamo commented Nov 15, 2020

I think the telemetry related stack trace is logged and ignored and the install moves forward. But then it fails here gatsby-cli@2.13.1 postinstall: node scripts/postinstall.js`

I cleaned up my debug build, would you mind testing again with this: npm i -g gatsby-cli@2.12.100-telemetry-test.518+061bd7f1b1 (note the version did change even though it seems similar).

@shivayan-bora
Copy link

It worked! Didn't get any errors now:

[Shivayan] npm i -g gatsby-cli@2.12.100-telemetry-test.518+061bd7f1b1                                         17:37:17
npm WARN deprecated @hapi/joi@15.1.1: joi is leaving the @hapi organization and moving back to 'joi' (https://github.com/sideway/joi/issues/2411)
npm WARN deprecated @hapi/address@2.1.4: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/bourne@1.3.2: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/hoek@8.5.1: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated @hapi/topo@3.1.6: This version has been deprecated and is no longer supported or maintained
npm WARN deprecated core-js@2.6.11: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
/root/.nvm/versions/node/v12.16.1/bin/gatsby -> /root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli/cli.js    
> gatsby-telemetry@1.3.36-telemetry-test.523 postinstall /root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry
> node -e "try{require('./lib/postinstall')}catch(e){}" || true


> gatsby-cli@2.12.100-telemetry-test.518 postinstall /root/.nvm/versions/node/v12.16.1/lib/node_modules/gatsby-cli
> node -e "try{require('./scripts/postinstall')}catch(e){}" || true

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/gatsby-cli/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

+ gatsby-cli@2.12.100-telemetry-test.518
updated 3 packages in 27.703s

@jamo
Copy link
Contributor

jamo commented Nov 15, 2020

Perfect, thanks for helping out!

And here is PR #28067 with the changes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: cli Related to the Gatsby CLI type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

9 participants