Core-js: Cannot find module in core-js when running from NPX

Created on 20 May 2019  ·  18Comments  ·  Source: zloirock/core-js

Before the latest change, all was fine, but now if I try to run npx bolt --version on CircleCI I get this error pointing at your package.

I know you had a recent change around postinstall and I know this isn't a bolt issue because it happens with other packages that have core-js as a dependency too.

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

Error: Cannot find module '/root/.npm/_npx/51/lib/node_modules/bolt/node_modules/core-js/scripts/postinstall'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:266:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:596:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/postinstall`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] 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-05-20T09_53_15_750Z-debug.log
Install for [email protected] failed with code 1
Exited with code 1

Most helpful comment

It's already released in [email protected] and [email protected].

All 18 comments

As you can see, this module exists on NPM. That looks like a bug with cache.

Same here, not aware of that we have configured any caching here, probably CircleCI does internally ...

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

Error: Cannot find module '/root/.npm/_npx/75/lib/node_modules/swagger-cli/node_modules/core-js/scripts/postinstall'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
at Function.Module._load (internal/modules/cjs/loader.js:507:25)
at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
at startup (internal/bootstrap/node.js:279:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:752:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: node scripts/postinstall
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] 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-05-20T11_44_15_343Z-debug.log
Install for swagger-cli@latest failed with code 1
cp: cannot stat ‘redoc-static.html’: No such file or directory
Exited with code 1`

Yes @jakobdoc, I have a very simple build config with no explicit caching. It's obviously an error between npx, core-js and cirlce ci, but I can't figure out exactly what's causing it.

I can confirm it only occurs using npx on the CircleCI machine. Using npm install -g it works...

We are using Gitlab-CI and we do not have any cache configured for our node_modules.

I have this error in multiple place, where we use npx:

Error: Cannot find module '/root/.npm/_npx/1355/lib/node_modules/@yeutech/gitlab-to-github/node_modules/core-js/scripts/postinstall'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:696:3)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/postinstall`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

and

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

Error: Cannot find module '/root/.npm/_npx/457/lib/node_modules/@yeutech-lab/rollup-umd-documentation-cli/node_modules/core-js/scripts/postinstall'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15)
    at Function.Module._load (internal/modules/cjs/loader.js:507:25)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:696:3)

I am now testing a fix to save the presentation I have on thursday for the 1st error using @jakobdoc solution to use npm install -g, in my script:

  if [[ ${NO_NPX_TRANSITIVE} = true ]]; then
    npm install -g @yeutech/gitlab-to-github
    npx @yeutech/gitlab-to-github github repository gitlab-to-github \
      "${name}" "${GH_TOKEN:-$GITHUB_TOKEN}" "${TRAVIS_CI_TOKEN}" \
      --organization="${org}" \
      --exclude="${SNAPSHOT_BRANCH}" \
      --dev-source="${DEV_SOURCE}" \
      --dev-target="${DEV_TARGET}" \
      --desc="${description}" \
      --homepage="${homepage}"
    npm uninstall -g @yeutech/gitlab-to-github
  else
    npx @yeutech/gitlab-to-github github repository gitlab-to-github \
      "${name}" "${GH_TOKEN:-$GITHUB_TOKEN}" "${TRAVIS_CI_TOKEN}" \
      --organization="${org}" \
      --exclude="${SNAPSHOT_BRANCH}" \
      --dev-source="${DEV_SOURCE}" \
      --dev-target="${DEV_TARGET}" \
      --desc="${description}" \
      --homepage="${homepage}"
  fi

Looking forward for a reason and a workaround/fix that does not imply to update our script.

I have opened a ticket with circleci and I suggest others do the same. In the meantime it would help if this call to post install were removed otherwise many people need to refactor out their use of npx in many different places @zloirock ? Whaddayasay, can ya help us out?!

I dont believe circleci would help, considering i am using travis and gitlabci and have the same issue..

Ah thanks for letting me know, I had only heard of CircleCI having the
issue up until now. So it is somehow between npx and libs that depend on
core-js.

On Tue, 21 May 2019 at 12:03, Dimitri KOPRIWA notifications@github.com
wrote:

I dont believe circleci would help, considering i am using travis and
gitlabci and have the same issue..


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/zloirock/core-js/issues/551?email_source=notifications&email_token=AA2R6F3FPF5OSXGOMFUFGXDPWPJGTA5CNFSM4HOAOX22YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODV3RS6Y#issuecomment-494344571,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AA2R6F2H3FV42DUWZXVVYD3PWPJGTANCNFSM4HOAOX2Q
.

--
Jason Green

Principal Developer Email: jason.[email protected]
christina.s@threadsstyling.com Mobile: +44 7462 752 694
<++44+7462+752+694>

[image: Snapchat] https://www.snapchat.com/add/threads_styling [image:
Instagram] https://www.instagram.com/threadsstyling [image: LinkedIn]
https://api.whatsapp.com/send?phone=447881362517

This email and any files transmitted with it are confidential and intended
solely for the use of the individual or entity to whom they are addressed.
If you have received this email in error please notify the system manager.
This message contains confidential information and is intended only for the
individual named. If you are not the named addressee you should not
disseminate, distribute or copy this e-mail. Please notify the sender
immediately by e-mail if you have received this e-mail by mistake and
delete this e-mail from your system. If you are not the intended recipient
you are notified that disclosing, copying, distributing or taking any
action in reliance on the contents of this information is strictly
prohibited.

getting this too now on shippable, highly doubt it's both shippable and circleci, prob something wrong with recent release?

> [email protected] postinstall /root/.nvm/versions/node/v8.15.0/lib/node_modules/karma/node_modules/core-js
> node scripts/postinstall

module.js:472
    throw err;
    ^

Error: Cannot find module '/root/.nvm/versions/node/v8.15.0/lib/node_modules/karma/node_modules/core-js/scripts/postinstall'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.runMain (module.js:605:10)
    at run (bootstrap_node.js:427:7)
    at startup (bootstrap_node.js:151:9)
    at bootstrap_node.js:542:3
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/karma/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/gulp/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] postinstall: `node scripts/postinstall`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@lukehutton I have checked and nothing to blame here.

Perhaps we should blame npx? Please link the issue here if someone does it.

Sorry to ask @zloirock, but because this module is in a middle of many chains of modules, maybe we could release a new version with a quick and ugly fix. By making the postinstall script mandatory for example?

Looking at postinstall.js content, we have:

/* eslint-disable no-console,max-len */
var env = process.env;
var CI = !!env.CI && env.CI !== '0' && env.CI !== 'false';
var SILENT = !!~['silent', 'error', 'warn'].indexOf(env.npm_config_loglevel);

if (!CI && !SILENT) {
  console.log('\u001B[96mThank you for using core-js (\u001B[94m https://github.com/zloirock/core-js \u001B[96m)!\u001B[0m\n');
  console.log('\u001B[96mPlease consider supporting of core-js on Open Collective or Patreon: \u001B[0m');
  console.log('\u001B[96m>\u001B[94m https://opencollective.com/core-js \u001B[0m');
  console.log('\u001B[96m>\u001B[94m https://www.patreon.com/zloirock \u001B[0m\n');
  console.log('\u001B[96mAlso, the author of core-js (\u001B[94m https://github.com/zloirock \u001B[96m) is looking for a good job -)\u001B[0m\n');
}

Nothing is required for the good sack of the software, perhaps someone can give a job to @zloirock :)?

This is a fix that would work, by editing package.json with:

  "scripts": {
-    "postinstall": "node scripts/postinstall"
+    "postinstall": "node scripts/postinstall || true"
  }

Looking at usage here, we would all want a 2.6.x fix.

Also, could we please edit the title and remove the Circle-CI reference?

Ok I see thanks, just thought perhaps errors were happening coinciding with a release

In the meantime it would help if this call to post install were removed

I thought about it but after some comments from #548 existence of postinstall is a principal position.

This is a fix that would work, by editing package.json with...

I'm not sure that it will work.

I still can't reproduce it with NPX and on my CI servers...

Maybe this would work?

"scripts": {
  "postinstall": "node -e \"try { require('./scripts/postinstall') } catch (_) {}\""
}

@nicolo-ribaudo something like that makes sense 👍

Thanks for the fix, is it released yet? Will you release a 2.6.x with it?

It's already released in [email protected] and [email protected].

I am still seeing errors (happened since v2.6.6):

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\development\\lang\\nodejs\\node.exe" "C:\\development\\lang\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v4.9.1
npm ERR! npm  v2.15.11
npm ERR! file C:\Windows\system32\cmd.exe
npm ERR! path C:\Windows\system32\cmd.exe
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn C:\Windows\system32\cmd.exe

npm ERR! [email protected] postinstall: `node scripts/postinstall || echo "ignore"`
npm ERR! spawn C:\Windows\system32\cmd.exe ENOENT
npm ERR! 
npm ERR! Failed at the [email protected] postinstall script 'node scripts/postinstall || echo "ignore"'.
npm ERR! This is most likely a problem with the core-js package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node scripts/postinstall || echo "ignore"
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs core-js
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! 
npm ERR!     npm owner ls core-js
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\BuildAgent\work\6e656885a186975c\wra\npm-debug.log

core-js is installed as a dependency of babel-preset-stage-0@^6.24.1 - I guess the length of the path exceeds the length supported by Windows' cmd.exe.

Was this page helpful?
0 / 5 - 0 ratings