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

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

Closed
yesmeck opened this issue Dec 28, 2018 · 33 comments
Closed

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

yesmeck opened this issue Dec 28, 2018 · 33 comments

Comments

@yesmeck
Copy link

yesmeck commented Dec 28, 2018

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
Copy link

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

@jlandersen
Copy link

Broke several packages I use as well

@matthewp
Copy link

cc @balupton how can we help with this?

@balupton
Copy link
Member

just spotted this

@balupton
Copy link
Member

looking into it

@balupton
Copy link
Member

balupton commented Dec 28, 2018

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
Copy link
Author

yesmeck commented Dec 28, 2018

[0] % node -v
v10.5.0
[0] % yarn -v
1.12.0

@balupton
Copy link
Member

Would someone be able to do this for me:

cd ./node_modules/errlop
node -e 'console.log(require("editions"))'

@mfasman95
Copy link

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
Copy link
Author

yesmeck commented Dec 28, 2018

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
Copy link

I saw the same as @yesmeck

@balupton
Copy link
Member

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
Copy link
Author

yesmeck commented Dec 28, 2018

I guess the reason is the circular dependencies.

@yesmeck
Copy link
Author

yesmeck commented Dec 28, 2018

errlop and editions are depending on each other.

@balupton
Copy link
Member

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
Copy link
Member

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

Can someone setup a repo that fails

@yesmeck
Copy link
Author

yesmeck commented Dec 28, 2018

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

@kostaspt
Copy link

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

image

@mfasman95
Copy link

I just traced down the dependency chain for my project.
[email protected] -> [email protected] -> [email protected] -> [email protected] -> [email protected] -> (loop)

@balupton
Copy link
Member

balupton commented Dec 28, 2018

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

  • is there anyone on macos who it is failing for?
  • is there anyone on windows who it is working for?

@mfasman95
Copy link

I am on macos

@balupton
Copy link
Member

well there goes that

@mfasman95
Copy link

mfasman95 commented Dec 28, 2018

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:
[email protected]
[email protected]
[email protected]

@balupton
Copy link
Member

balupton commented Dec 28, 2018

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
Copy link

mfasman95 commented Dec 28, 2018

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 added a commit to bevry/editions that referenced this issue Dec 28, 2018
should function as a workaround for bevry/errlop#2
@balupton
Copy link
Member

okay, been able to reproduce

@ylecuyer
Copy link

YOLO package updating XD

@balupton
Copy link
Member

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

@balupton
Copy link
Member

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
Copy link

Works for me now, thanks!

@mfasman95
Copy link

Worked for me as well. Thank you!

@matthewp
Copy link

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

@balupton
Copy link
Member

balupton commented Dec 28, 2018

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

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