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

package.json missing a main key #125

Closed
jude opened this issue May 7, 2023 · 2 comments
Closed

package.json missing a main key #125

jude opened this issue May 7, 2023 · 2 comments

Comments

@jude
Copy link
Contributor

jude commented May 7, 2023

Describe the bug

require("leaflet.browser.print") is failing to find the leaflet.browser.print module.

If I add a main': 'dist/leaflet.browser.print.js key/value to package.json, the module is found.

As per https://docs.npmjs.com/cli/v9/configuring-npm/package-json#main, main defaults to index.js in the package's root folder. but there is no index.js in this module.

To Reproduce

  • Include 'leaflet.browser.print' as a dependency in your project's package.json file
  • Verify that leaflet.browser.print is included in your node_modules directory
  • Include a require('package.browser.print') line in your project's index.js file
  • 'npm start' fails with the error below
> browserify -d src/index.js -s myproject > bundle.raw.js && uglifyjs bundle.raw.js -c -m --source-map "filename=bundle.js.map" -o bundle.js

Error: Cannot find module 'leaflet.browser.print' from '/opt/myproject/src'
    at /opt/myproject/node_modules/browserify/node_modules/browser-resolve/node_modules/resolve/lib/async.js:46:17
...

Expected behavior

  • npm build doesn't give an error about not being to find the module.

Screenshots
n/a

Desktop (please complete the following information):
n/a

Smartphone (please complete the following information):
n/A

Additional context
This is a 1 line fix that I'll submit an PR for momentarily.

jude added a commit to jude/leaflet.browser.print that referenced this issue May 7, 2023
@Igor-Vladyka
Copy link
Owner

Great, thanks.

@gugudetbaba
Copy link

Hello,
if I install via npm, the main key is still missing in the package.json. Maybe it is just a problem on my system, nonetheless I wanted to mention it.

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

3 participants