bevry / errlop

An extended Error class that envelops a parent error, such that the stack trace contains the causation
Other
9 stars 2 forks source link

TypeError: require(...).requirePackage is not a function #2

Closed yesmeck closed 5 years ago

yesmeck commented 5 years ago

My app works fine a hour ago, but after a refresh npm install, I got this error, and I found that errlop was just released a new version. So I guess the new version of errlop has some breaking changes.

/Users/meck/Workspace/app/node_modules/errlop/index.js:4
module.exports = require('editions').requirePackage(__dirname, require)
                                     ^

TypeError: require(...).requirePackage is not a function
    at Object.<anonymous> (/Users/meck/Workspace/app/node_modules/errlop/index.js:4:38)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/meck/Workspace/dchain-frontend/node_modules/editions/edition-node-0.8/index.js:12:14)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
error Command failed with exit code 1.
matthewp commented 5 years ago

Same here. I see that these are circular dependencies. Is this a new thing?

jlandersen commented 5 years ago

Broke several packages I use as well

matthewp commented 5 years ago

cc @balupton how can we help with this?

balupton commented 5 years ago

just spotted this

balupton commented 5 years ago

looking into it

balupton commented 5 years ago

if others can look into it too, that would be appreciated

what node verison, and what npm version are people using?

as I cannot reproduce it on my own machine.

yesmeck commented 5 years ago
[0] % node -v
v10.5.0
[0] % yarn -v
1.12.0
balupton commented 5 years ago

Would someone be able to do this for me:

cd ./node_modules/errlop
node -e 'console.log(require("editions"))'
mfasman95 commented 5 years ago

I encountered this issue on Node 10.13.0 with NPM 6.4.1.

I noticed this version bump in what appears to be the most recent commit with significant changes (from ~2 hours ago). Was there an API change with the editions library moving to version 2.x?

yesmeck commented 5 years ago

Same error:

[0] % node -e 'console.log(require("editions"))'

/Users/meck/Workspace/app/node_modules/errlop/index.js:4
module.exports = require('editions').requirePackage(__dirname, require)
                                     ^

TypeError: require(...).requirePackage is not a function
    at Object.<anonymous> (/Users/meck/Workspace/app/node_modules/errlop/index.js:4:38)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
    at Module.load (internal/modules/cjs/loader.js:612:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
    at Function.Module._load (internal/modules/cjs/loader.js:543:3)
    at Module.require (internal/modules/cjs/loader.js:650:17)
    at require (internal/modules/cjs/helpers.js:20:18)
    at Object.<anonymous> (/Users/meck/Workspace/dchain-frontend/node_modules/editions/edition-node-0.8/index.js:12:14)
    at Module._compile (internal/modules/cjs/loader.js:702:30)
mfasman95 commented 5 years ago

I saw the same as @yesmeck

balupton commented 5 years ago

I noticed this version bump in what appears to be the most recent commit with significant changes (from ~2 hours ago). Was there an API change with the editions library moving to version 2.x?

two changes:

  1. editions v2 has internal changes, no API changes
  2. editions v2 now uses errlop within it
yesmeck commented 5 years ago

I guess the reason is the circular dependencies.

yesmeck commented 5 years ago

errlop and editions are depending on each other.

balupton commented 5 years ago

errlop and editions are depending on each other.

circular dependencies have been supported in npm since I think v2 or v3

I also can't seem to reproduce this on my end

balupton commented 5 years ago

I've setup https://github.com/balupton/errlop-issue-2 which works fine for me

Can someone setup a repo that fails

yesmeck commented 5 years ago

You can try running the tests of https://github.com/bevry/istextorbinary, they also failed with the above error on my end.

kostaspt commented 5 years ago

@balupton Your repo works fine for me too, but running npx oclif multi mynewcli is failing.

image

mfasman95 commented 5 years ago

I just traced down the dependency chain for my project. yeoman-generator@4.1.1 -> istextorbinary@2.3.0 -> editions@2.1.0 -> errlop@1.1.0 -> editions@2.1.0 -> (loop)

balupton commented 5 years ago

interesting, maybe it is due to how the package managers handle symlinks cross platform

mfasman95 commented 5 years ago

I am on macos

balupton commented 5 years ago

well there goes that

mfasman95 commented 5 years ago

I just made a fresh package to test something.

{
  "name": "temp",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "dependencies": {
    "istextorbinary": "^2.3.0"
  }
}
const istextorbinary = require('istextorbinary');

console.log(istextorbinary('hello world'));
/Users/mfasman/temp/node_modules/errlop/index.js:4
module.exports = require('editions').requirePackage(__dirname, require)
                                     ^

TypeError: require(...).requirePackage is not a function
    at Object.<anonymous> (/Users/mfasman/temp/node_modules/errlop/index.js:4:38)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
    at Function.Module._load (module.js:497:3)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/mfasman/temp/node_modules/editions/edition-node-0.8/index.js:12:14)
    at Module._compile (module.js:652:30)

I got the same error on two node versions: Node 8.11.3 - NPM 5.6.0 Node 10.13.0 - NPM 6.4.1

Dependencies as listed in lock file/resolved in node_modules: istextorbinary@2.3.0 errlop@1.1.0 editions@2.1.0

balupton commented 5 years ago

working on a release of editions right now that skips errlop's dependency on it, and will release new versions for both

perhaps this is happening because there are multiple editions v2 versions being installed at the same time

can someone gist their package-lock.json

mfasman95 commented 5 years ago

yarn.lock

# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1

binaryextensions@^2.1.2:
  version "2.1.2"
  resolved "{HOSTED_NPM}/binaryextensions/-/binaryextensions-2.1.2.tgz#c83c3d74233ba7674e4f313cb2a2b70f54e94b7c"
  integrity sha1-yDw9dCM7p2dOTzE8sqK3D1TpS3w=

editions@^2.0.2, editions@^2.1.0:
  version "2.1.0"
  resolved "{HOSTED_NPM}/editions/-/editions-2.1.0.tgz#5c6f6341ef19ee362a3bcbb907fe68e696dbc69e"
  integrity sha1-XG9jQe8Z7jYqO8u5B/5o5pbbxp4=
  dependencies:
    errlop "^1.0.3"
    semver "^5.6.0"

errlop@^1.0.3:
  version "1.1.0"
  resolved "{HOSTED_NPM}/errlop/-/errlop-1.1.0.tgz#34da3df1fc595585c94cb67c178d694da24470de"
  integrity sha1-NNo98fxZVYXJTLZ8F41pTaJEcN4=
  dependencies:
    editions "^2.1.0"

istextorbinary@^2.3.0:
  version "2.3.0"
  resolved "{HOSTED_NPM}/istextorbinary/-/istextorbinary-2.3.0.tgz#29458d7b10edcb52f4db9c57945bb67cd20cc4fd"
  integrity sha1-KUWNexDty1L025xXlFu2fNIMxP0=
  dependencies:
    binaryextensions "^2.1.2"
    editions "^2.0.2"
    textextensions "^2.4.0"

semver@^5.6.0:
  version "5.6.0"
  resolved "{HOSTED_NPM}/semver/-/semver-5.6.0.tgz#7e74256fbaa49c75aa7c7a205cc22799cac80004"
  integrity sha1-fnQlb7qknHWqfHogXMInmcrIAAQ=

textextensions@^2.4.0:
  version "2.4.0"
  resolved "{HOSTED_NPM}/textextensions/-/textextensions-2.4.0.tgz#6a143a985464384cc2cff11aea448cd5b018e72b"
  integrity sha1-ahQ6mFRkOEzCz/Ea6kSM1bAY5ys=

Edit to clarify: I have encountered this with both yarn and NPM, so that is unlikely to be the cause.

balupton commented 5 years ago

okay, been able to reproduce

ylecuyer commented 5 years ago

YOLO package updating XD

balupton commented 5 years ago

alright, try rm -rf node_modules package-lock.json yarn.lock then npm install and cross your fingers with me

balupton commented 5 years ago

gonna have a shower (is quite late in sydney), let me know if it resolved or not with the latest versions of editions and errlop

kostaspt commented 5 years ago

Works for me now, thanks!

mfasman95 commented 5 years ago

Worked for me as well. Thank you!

matthewp commented 5 years ago

@balupton 👏 you are amazing. Thanks for spending time on this.

balupton commented 5 years ago

fantastic, thanks everyone for the speedy reports, you were all fantastic in debugging this, good work. I'm off to bed! Sorry for the inconvenience. Happy holidays