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

debug no longer works with browserify #606

Closed
wraithgar opened this issue Sep 11, 2018 · 20 comments · Fixed by #607, houby-studio/small-business-fridge#7 or mieweb/froo2#7 · May be fixed by snyk-fixtures/npm-lockfiles#1579 or snyk-fixtures/npm-lockfiles#1614
Assignees
Labels
bug This issue identifies a malfunction

Comments

@wraithgar
Copy link

Any version of debug that I use past version 3.1.0 gives this error when trying to browserify code that includes this module

Cannot find module './common' from '[redacted]/node_modules/debug/dist'
      at FSReqWrap.oncomplete (fs.js:154:21)

There was a mention in #603 about a browserify incompatibility, but it doesn't appear to be the same issue.

@Qix-
Copy link
Member

Qix- commented Sep 11, 2018

Hi - which version exactly is being pulled down?

@gztomas
Copy link

gztomas commented Sep 11, 2018

Hi @Qix- , my team is experiencing the same exact issue. We are pulling v3.2.4

@wraithgar
Copy link
Author

I get that same error with versions 3.2.3, 3.2.4, and 4.0.0

@Qix-
Copy link
Member

Qix- commented Sep 11, 2018

Interesting, I'll take a look - give me a moment.

To be clear, you shouldn't be pulling 3.2.x at all - should either be 3.1.0 or 4.0.0. the 3.2.x range was deprecated and only existed to help users affected at the time of the incident.

Pulling debug from npm should act as though the 3.2 range does not exist.

@gztomas
Copy link

gztomas commented Sep 11, 2018

@Qix- maybe it is that we are using martifactory registry as a caching proxy in the middle which is not aware yet of that deprecation. I will look into that.

@kolegm
Copy link

kolegm commented Sep 11, 2018

the same issue for me with debug@4.0.0
Reason: Error: Cannot find module './common' from 'node_modules/debug/dist'

@Qix-
Copy link
Member

Qix- commented Sep 11, 2018

Does the code on unpkg match the code in the node_modules/debug/dist/debug.js folder?

https://unpkg.com/debug@4.0.0/dist/debug.js

If so, then there's no reason this shouldn't work. This is the same invocation of browserify as before, just with babel thrown on to it (which shouldn't affect anything).

Could you also give more information as to how you're using debug? Some reproduction steps would help.

image

image

@Qix- Qix- added the bug This issue identifies a malfunction label Sep 11, 2018
@Qix-
Copy link
Member

Qix- commented Sep 11, 2018

I can't help fix this without some reproduction steps. debug works in the browser for me.

@wraithgar
Copy link
Author

Deep requiring into a specific file in the package from an unpkg url is not exactly a "works in the browser" test that feels like it was made in good faith. Here's a barebones "try debug with browserify" that breaks (assumes you have npm@6 so that npx is a command you can run):

$ npm init -y
$ npm install debug@latest browserify@latest
$ echo "var log = require('debug')('example')" >example.js
$ npx browserify example.js
Error: Cannot find module './common' from '/usr/local/src/gar/projects/example/node_modules/debug/dist'
    at /usr/local/src/gar/projects/example/node_modules/browser-resolve/node_modules/resolve/lib/async.js:55:21
    at load (/usr/local/src/gar/projects/example/node_modules/browser-resolve/node_modules/resolve/lib/async.js:69:43)
    at onex (/usr/local/src/gar/projects/example/node_modules/browser-resolve/node_modules/resolve/lib/async.js:92:31)
    at /usr/local/src/gar/projects/example/node_modules/browser-resolve/node_modules/resolve/lib/async.js:22:47
    at FSReqWrap.oncomplete (fs.js:154:21)

@Qix-
Copy link
Member

Qix- commented Sep 11, 2018

Deep requiring into a specific file in the package from an unpkg url is not exactly a "works in the browser" test that feels like it was made in good faith.

Feel free to submit a PR that automates this testing. The release wasn't made in "bad faith", if that's what you're suggesting. I'm one person managing a package that is downloaded several million times per day - all I can do is help fix problems where they arise.

The alternative is to not release ever again, which solves nothing.


Thank you for the reproduction steps - I can confirm they reproduce.

@Qix- Qix- self-assigned this Sep 11, 2018
@Qix-
Copy link
Member

Qix- commented Sep 11, 2018

Unpkg uses the browser field, in my opinion, erroneously. They do supply an unpkg field apparently.

I'll revert browser to src/browser.js and add "unpkg": "dist/debug.js". That should fix both cases.

PR incoming.

@Qix-
Copy link
Member

Qix- commented Sep 11, 2018

Some input on #607 would be appreciated. You can test this version by running npm i 'visionmedia/debug#fix-browserify'.

@gztomas
Copy link

gztomas commented Sep 11, 2018

Could this be included in a 3.2.5 release? We are still getting 3.2.4 when using yarn

@Qix-
Copy link
Member

Qix- commented Sep 11, 2018

@gztomas sure.

@Qix-
Copy link
Member

Qix- commented Sep 11, 2018

Released as 4.0.1 and backported to 3.2.5.

Even though this issue is closed let me know here if that doesn't solve it.

@gztomas
Copy link

gztomas commented Sep 11, 2018

Working for us! Thanks for the awesome support!

@Qix-
Copy link
Member

Qix- commented Sep 12, 2018

No problem, thank you for following up @gztomas

@ThomasGHenry
Copy link

Back in business, @Qix- ! Thanks for your hard work! I do not envy your position these past several hours. What a nightmare, but well met!

@Qix-
Copy link
Member

Qix- commented Sep 12, 2018

Thank you @ThomasGHenry, sorry for the trouble :)

@nealyip
Copy link

nealyip commented Dec 8, 2018

Hi, I found this fix broke Angular/Webpack.
I am a user of aws-appsync. Since a recent release, the debug package is added to their dependencies.
However, IE11 no longer worked as Angular/Webpack utilized the browser property from debug's package.json when bundling.
awslabs/aws-mobile-appsync-sdk-js#310

It worked immediately if I edited the file node_modules/aws-appsync/debug/package.json and turned browser back to "./dist/debug.js" as webpack used that file instead of src/browser.js for a browser.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment