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

Cannot find module in core-js when running from NPX #551

Closed
jasoniangreen opened this issue May 20, 2019 · 18 comments
Closed

Cannot find module in core-js when running from NPX #551

jasoniangreen opened this issue May 20, 2019 · 18 comments

Comments

@jasoniangreen
Copy link

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! core-js@2.6.6 postinstall: `node scripts/postinstall`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the core-js@2.6.6 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 bolt@0.22.5 failed with code 1
Exited with code 1
@zloirock
Copy link
Owner

zloirock commented May 20, 2019

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

@jakobdoc
Copy link

jakobdoc commented May 20, 2019

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! core-js@2.6.6 postinstall: node scripts/postinstall
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the core-js@2.6.6 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`

@jasoniangreen
Copy link
Author

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.

@jakobdoc
Copy link

jakobdoc commented May 20, 2019

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

@kopax
Copy link

kopax commented May 20, 2019

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! core-js@2.6.6 postinstall: `node scripts/postinstall`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the core-js@2.6.6 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.

@jasoniangreen
Copy link
Author

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?!

@kopax
Copy link

kopax commented May 21, 2019

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

@jasoniangreen
Copy link
Author

jasoniangreen commented May 21, 2019 via email

@lukehutton
Copy link

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

> core-js@2.6.7 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: fsevents@1.2.9 (node_modules/karma/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.9 (node_modules/gulp/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! core-js@2.6.7 postinstall: `node scripts/postinstall`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the core-js@2.6.7 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

@kopax
Copy link

kopax commented May 21, 2019

@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?

@lukehutton
Copy link

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

@zloirock
Copy link
Owner

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.

@zloirock zloirock changed the title Cannot find module in core-js when running from CircleCI Cannot find module in core-js when running from NPX May 21, 2019
@zloirock
Copy link
Owner

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

@nicolo-ribaudo
Copy link
Contributor

Maybe this would work?

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

@zloirock
Copy link
Owner

@nicolo-ribaudo something like that makes sense 👍

@kopax
Copy link

kopax commented May 22, 2019

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

@zloirock
Copy link
Owner

It's already released in core-js@3.1.2 and core-js@2.6.8.

@robi-wan
Copy link

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! core-js@2.6.9 postinstall: `node scripts/postinstall || echo "ignore"`
npm ERR! spawn C:\Windows\system32\cmd.exe ENOENT
npm ERR! 
npm ERR! Failed at the core-js@2.6.9 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants