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

[Bug]: Failed to resolve entry for package "@materializecss/materialize #455

Open
3 tasks done
axelf opened this issue Feb 20, 2024 · 5 comments
Open
3 tasks done
Labels
bug Something isn't working

Comments

@axelf
Copy link

axelf commented Feb 20, 2024

Before submitting...

Context

Hi,
i want to use materialize in a laravel / vite project.

Current Behavior

After importing the package in my app.js
import { Sidenav } from '@materializecss/materialize';

i got this message:
Failed to resolve entry for package "@materializecss/materialize". The package may have incorrect main/module/exports specified in its package.json.

Expected behavior

Import this module without error messages

Possible Solutions or Causes

No response

Steps to reproduce

No response

Your Environment

  • Version used: 2.0.3
  • Browser Name and version: Firefox 122
  • Operating System and version (desktop or mobile): macOS Sonoma 14.2.1
  • Additional information you want to tell us:
@axelf axelf added the bug Something isn't working label Feb 20, 2024
@danice
Copy link

danice commented Feb 20, 2024

Hello,
Materialize-docs is an example of using materialize from a vite project. Can you provide an example project to test this issue?

Thanks!

@axelf
Copy link
Author

axelf commented Feb 20, 2024

@danice i made i git repository: https://github.com/axelf/materialize-vite
You can downlaod the code and after a npm install and npm run dev you see the error:
Bildschirmfoto 2024-02-20 um 21 03 14

@axelf
Copy link
Author

axelf commented Feb 20, 2024

This is working: import { M } from "@materializecss/materialize/dist/js/materialize.js";
This is the path of the main entry of the package json.
But why isimport { M } from "@materializecss/materialize"; not working?

It is working, but this says the editor if i hover over the import statement:

Could not find a declaration file for module '@materializecss/materialize/dist/js/materialize.js'. '/myproject/node_modules/@materializecss/materialize/dist/js/materialize.js' implicitly has an 'any' type. If the '@materializecss/materialize' package actually exposes this module, try adding a new declaration (.d.ts) file containing declare module '@materializecss/materialize/dist/js/materialize.js';ts(7016) module "/myproject/node_modules/@materializecss/materialize/dist/js/materialize"

@danice
Copy link

danice commented Feb 21, 2024

it's because the package has also this entry that takes preference in the import:
"module": "src/index.ts",

This "module" was not causing problems when importing the library using webpack and it make it work when using it as a workspace (as in materialize-docs).

I think we should replace "src/index.ts" here by the ".d.ts" that your comment says. But we should check that it keeps the library working when used from webpack and as a workspace.

@axelf
Copy link
Author

axelf commented Feb 21, 2024

@danice thank you for helping me out.

For now should i leave the import as it is import { M } from "@materializecss/materialize/dist/js/materialize.js and ignore the error in my code editor? I don't mind the marking in the editor and it works like this for now

danice added a commit to danice/materialize that referenced this issue Feb 29, 2024
this was causing issue: failed to resolve entry for package "@materializecss/materialize materializecss#455
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants