profile
viewpoint

Ask questions[gatsby-telemetry] error: src/postinstall.js not found in Linux environments

Description

In a Linux instance, Gatsby CLI is breaking currently because it doesn't find src/postinstall.js from gatsby-telemetry when running gatsby new with NPX.

Steps to reproduce

  1. Spin up a linux instance (Either a VM or container)
  2. Download Node (tested on both 10 and 12 and breaks on both)
  3. run npx gatsby new .

Expected result

Should just run

Actual result

Error:

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

Error: Cannot find module '/root/.npm/_npx/17/lib/node_modules/gatsby/node_modules/core-js/scripts/postinstall'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:840:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
internal/modules/cjs/loader.js:628
    throw err;
    ^

Error: Cannot find module '/root/.npm/_npx/17/lib/node_modules/gatsby/node_modules/core-js-pure/scripts/postinstall'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:840:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
internal/modules/cjs/loader.js:628
    throw err;
    ^

Error: Cannot find module '/root/.npm/_npx/17/lib/node_modules/gatsby/node_modules/gatsby-telemetry/src/postinstall.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
    at Function.Module._load (internal/modules/cjs/loader.js:527:27)
    at Function.Module.runMain (internal/modules/cjs/loader.js:840:10)
    at internal/main/run_main_module.js:17:11 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! gatsby-telemetry@1.1.11 postinstall: `node src/postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the gatsby-telemetry@1.1.11 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/2019-08-01T21_57_39_926Z-debug.log
Install for [ 'gatsby@latest' ] failed with code 1

This may be an issue with this commit: https://github.com/gatsbyjs/gatsby/commit/9d32f3cf45a8155018c4fae0d5ad80f0e195a348

Environment

Run gatsby info --clipboard in your project directory and paste the output here.

gatsbyjs/gatsby

Answer questions lannonbr

@jamo Yeah it was a colleague of mine that was getting stuck with this, he did npm i -g gatsby-cli in the docker container he was working in to get around this issue for the time being.

useful!

Related questions

Error: Cannot create as TypeComposer the following value: Date. hot 3
Importing Link from gatsby breaks Storybook hot 2
Loading chunks while a new release is deployed hot 2
Webpack error #98123 when running "gatsby develop" hot 2
gatsby build error #11328 A page component must export a React component for it to be valid. Please make sure this file exports a React component: /Users/tiagosanchez/Documents/Projects/personalBlog/node_modules/gatsby-plugin-offline/app-shell.js hot 2
IE11: Object not valid as React Child hot 2
CircleCI build Error: spawn ENOMEM hot 2
[Help] I somehow managed to butcher my site's performance hot 2
Build gets stuck at Generating image thumbnails / Update schema on large sites hot 2
[gatsby-source-graphql] Shopify GraphQL Schema Error hot 2
UNHANDLED REJECTION Source and destination must not be the same. hot 2
gatsby-source-shopify unable to complete build hot 2
Gatsby's Use Of Polyfills and the 'Missing Resources for x' error hot 2
Autoprefixer "browsers" option is deprecated in v9, produces warnings hot 2
'gatsby' is not recognized as an internal or external command hot 2
Github User Rank List