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

Failed to resolve entry for package "material-symbols" #2

Closed
enheit opened this issue May 13, 2022 · 2 comments
Closed

Failed to resolve entry for package "material-symbols" #2

enheit opened this issue May 13, 2022 · 2 comments

Comments

@enheit
Copy link

enheit commented May 13, 2022

After installing material-symbols using npm the following message is shown in the console

My steps

  1. Run in the console npm i material-symbols@latest
  2. Add import 'material-symbols'; at the top of the __layout.svelte file
  3. Add <span class="material-symbols-outlined">face</span> to the component file
  4. Open console
  5. Error message is shown

Error message

Failed to resolve entry for package "material-symbols". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "material-symbols". The package may have incorrect main/module/exports specified in its package.json.

P.S. I asked this question on StackOverflow too

Update

As was able to run this package by changing the approach. I replaced step 2 with CSS imports.

Instead of

// __layout.svelte

import 'material-symbols';

...

I created 'app.css' file in the src folder. Added @import 'material-symbols'; at the top of its file. Imported app.css into __layout.svelte.

/* app.css */
@import 'material-symbols';
// __layout.svelte 

- import 'material-symbols';
+ import '../app.css';

...

It works

@marella
Copy link
Owner

marella commented May 13, 2022

The material-symbols package uses the browser field in package.json to specify the entry point which is index.css.
I haven't used svelte but it looks like internally it is using a tool called vite which doesn't seem to handle browser field properly (see vitejs/vite#7576).
So as a workaround, you can add import 'material-symbols/index.css'; to your svelte file or add @import 'material-symbols'; in CSS like you mentioned.

@marella
Copy link
Owner

marella commented Jun 3, 2022

I changed browser field to main to avoid such issues in future with other tools. So import 'material-symbols'; will also work now in svelte files. Please try again after installing the latest version 0.2.0.

@marella marella closed this as completed Jun 3, 2022
This issue was closed.
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

2 participants