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 'package.json' #1

Closed
ntrrgc opened this issue Jan 20, 2017 · 7 comments · Fixed by #374
Closed

Cannot find module 'package.json' #1

ntrrgc opened this issue Jan 20, 2017 · 7 comments · Fixed by #374

Comments

@ntrrgc
Copy link

ntrrgc commented Jan 20, 2017

This plugin chokes on imports like this one:

import Bag from "typescript-collections/dist/lib/Bag";
🚨   Could not load commonjs-proxy:
<project>/node_modules/typescript-collections/dist/lib/util.js
(imported by <project>/node_modules/typescript-collections/dist/lib/Dictionary.js):
Cannot find module 'package.json'

typescript-collections has a package.json, of course.

@mjeanroy
Copy link
Owner

Thank you for your report.

That's weird, I just tried to bundle this module (typescript-collections), and I can't reproduce the problem. Can you share your configuration (package.json, rollup.config.js)?

@mjeanroy
Copy link
Owner

If you can't share your configuration, feel free to look at this repository to reproduce the problem: https://github.com/mjeanroy/test-rollup-plugin-license

@pran1990
Copy link

pran1990 commented Feb 25, 2018

FWIW, I'm running into this as well, on commonjs-proxy.

https://github.com/dropbox/dropbox-sdk-js/tree/license. I tried pasting my package.json and rollup.config.js into your test, which just generates an empty dependencies.txt for me.

Could not load commonjs-proxy:/Users/praneshp/code/dropbox-sdk-js/node_modules/base64-js/index.js (imported by /Users/praneshp/code/dropbox-sdk-js/node_modules/buffer/index.js): Cannot find module 'package.json'

@Havunen
Copy link

Havunen commented Dec 10, 2018

Same error occurred for me, I resolved it by re-ordering my rollup plugins.

@GerkinDev
Copy link
Contributor

@Havunen it would be nice if you could tell what you did... Move The plugin license up or down ? After which other plugin ?

Cheers

@GerkinDev
Copy link
Contributor

OK, I got it. The bug was caused by the leading NULL 0x00 Unicode character in front of the path of internal modules, typically added by Babel. So, hooking rollup-plugin-license before Babel could avoid the issue, but I strongly believe that those cases should be handled properly, because it's a norm wanted by rollup. See rollup/rollup#2121 for some related issues.

I've locally fixed the issue, and I'll try to find the time to do a proper PR.

Cheers!

@mjeanroy
Copy link
Owner

Thank you very much @GerkinDev for your report. I'm waiting for your PR, but if you don't have enough time, I can fix it myself.

MichaelKowal referenced this issue in vertigis/rollup-plugin-license Nov 28, 2022
…s-directory

Check that license file is actually a file
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

Successfully merging a pull request may close this issue.

5 participants