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

Can't resolve './types' #258

Open
Hmerman6006 opened this issue Aug 6, 2023 · 11 comments
Open

Can't resolve './types' #258

Hmerman6006 opened this issue Aug 6, 2023 · 11 comments
Labels
awaiting user Needs more information from OP. needs repro Needs a reproduction to get more help

Comments

@Hmerman6006
Copy link

When importing the component I get below output from npm:

ERROR in ./node_modules/svelte-multiselect/dist/index.js 5:0-24
.Module not found: Error: Can't resolve './types' in '/var/www/html/orodata-website/node_modules/svelte-multiselect/dist'
Did you mean 'types.js'?
BREAKING CHANGE: The request './types' failed to resolve only because it was resolved as fully specified
(probably because the origin is strict EcmaScript Module, e. g. a module with javascript mimetype, a '*.mjs' file, or a '*.js' file where the package.json contains '"type": "module"').
The extension in the request is mandatory for it to be fully specified.
Add the extension to the request.

I am not using TypeScript and I see the types.js file exports an empty object. How do I resolve this?

@janosh janosh added awaiting user Needs more information from OP. needs repro Needs a reproduction to get more help labels Aug 6, 2023
@janosh
Copy link
Owner

janosh commented Aug 6, 2023

Could you post a StackBlitz repro? Would be good to know what package versions you're using.

@Hmerman6006
Copy link
Author

Hmerman6006 commented Aug 9, 2023

Was a fresh install in a Laravel 8 environment with following package.json dependencies:

"scripts": {
      "dev": "mix",
      "development": "mix",
      "watch": "mix watch",
      "watch-poll": "mix watch -- --watch-options-poll=1000",
      "hot": "mix watch --hot",
      "prod": "mix --production",
      "production": "mix --production"
  },
  "devDependencies": {
      "@babel/core": "^7.16.0",
      "@babel/plugin-syntax-dynamic-import": "^7.8.3",
      "@babel/preset-env": "^7.16.0",
      "babel-loader": "^8.2.3",
      "laravel-mix": "^6.0.49",
      "laravel-mix-svelte": "^0.5.0",
      "lodash": "^4.17.19",
      "resolve-url-loader": "^3.1.0",
      "sass": "^1.32.13",
      "sass-loader": "^11.1.1",
      "svelte": "^3.1.0",
      "svelte-loader": "^2.13.4",
  },
  "dependencies": {
      "laravel-svelte-direct-mix": "0.0.1",
      "svelte-multiselect": "^10.1.0"
  }

Tried downgrading to v9, but did not work. Have not used StackBlitz yet: will try this weekend and send you feedback.

@janosh
Copy link
Owner

janosh commented Aug 9, 2023

Are you setting

"type": "module",

in your package.json?

@rocinante42
Copy link

+1 to this, I'm facing exactly the same issue

@rocinante42
Copy link

A fresh npm install solved it 🤔 weird, will look further into this to see what was triggering it

@627426p
Copy link

627426p commented Nov 9, 2023

Ill add to this, I'm facing the same issue.
Changing export * from './types'; to export * from './types.js'; in both the dist/index.js and dist/index.d.ts fixes it.
Fresh install did not change anything for me.

@hotmeteor
Copy link

I'm also hitting this error on an old project, same package.json as @Hmerman6006's example

@janosh
Copy link
Owner

janosh commented Mar 1, 2024

same question

Are you setting

"type": "module",

in your package.json?

@hotmeteor
Copy link

@janosh No I'm not

Thanks for the quick reply

@janosh
Copy link
Owner

janosh commented Mar 1, 2024

i'm not firm on the details but i think Svelte is ESM-only at this point

@hotmeteor
Copy link

hotmeteor commented Mar 1, 2024

Yeah but we're on Svelte 3, and this plugin used to work. I've even locked it back to version ^8.0 and no luck. Ah well, maybe someone finds something.

Edit:

OK "svelte": "^3.0.0" + "svelte-multiselect": "^7.0.0" seems to do the trick, so not sure what happened starting with v8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting user Needs more information from OP. needs repro Needs a reproduction to get more help
Projects
None yet
Development

No branches or pull requests

5 participants