-
Notifications
You must be signed in to change notification settings - Fork 159
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
Naming collision when installing punycode via npm #79
Comments
Maybe package-lock.json or a npm-shrinkwarp.json file helps here. |
IIRC there was a better way of preferring an npm-installed module over a Node-built-in module, although maybe I was dreaming. @zkat, do you know? |
This is literally impossible and unlikely to ever change. It is the first alternative in Node's module lookup algorithm, and so there's.... basically no actual way to do this besides referencing the module by path. I would be tremendously surprised if this -ever- worked -- you might consider using a |
Of course, the other alternative is to make Node's built-in |
Thank you, @zkat! |
Thanks @mathiasbynens :) |
Also, for my own future reference and general interest, I randomly spotted this gem in the eslint-plugin-node node/no-deprecated-api docs while closing some tabs:
$ node -e "console.log(require('punycode').version)" # 2.0.0
$ node -e "console.log(require('punycode/').version)" # 2.1.0 |
@pdehaan cool hacks! |
Ooh, that may have been the workaround I was trying to remember! I like |
Not that this is a democracy, but I like the new package name approach much better. It's a lot more obvious what's happening, and you wouldn't have to try explaining the odd looking trailing slash in the require statement. |
@mathiasbynens Can punycode.js package be updated to 2.1.1 as well? As I agree with @pdehaan as why require the use of a "hack" to be able to use the package. |
We currently use the built-in (and deprecated) punycode module instead of the userland dependency we pull in. Per mathiasbynens/punycode.js#79 (comment), we can simply add a slash to force Node's resolution algorithm to ignore the core module.
Refs mathiasbynens#79 This change updates the usage instructions in the README to explain the workaround required to use this module. As userland modules do not hide core modules, a trailing slash is required to have Node.js use this module over the built-in.
Refs #79 This change updates the usage instructions in the README to explain the workaround required to use this module. As userland modules do not hide core modules, a trailing slash is required to have Node.js use this module over the built-in.
I'm using Node 9.7.1, and have [email protected] installed (via $ npm i punycode -S), but when I try and log out the
punycode.version
variable, I always seem to get "2.0.0", so I think my machine is still using the default/bundled/deprecated version of https://nodejs.org/api/punycode.htmlHow can you install this module from npm and use it in Node 8+ without it using the built-in version of the punycode module? It looks like I can use the npm version if I do something like
require("./node_modules/punycode")
, but that feels wrong.The text was updated successfully, but these errors were encountered: