libraries that import relative path in node_modules
Curious how to import modules that have relative paths to was trying to import a node_module package: e.g. https://unpkg.com/browse/swrv@0.3.0/esm/index.js
[vite] Error while resolving node_modules with id "lib/cache.js":
{ Error: Cannot find module 'lib/package.json'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:668:15)
at resolveFileName (/Users/darrenjennings/source/repos/vite-sup/node_modules/resolve-from/index.js:29:39)
at resolveFrom (/Users/darrenjennings/source/repos/vite-sup/node_modules/resolve-from/index.js:43:9)
at Object.module.exports [as default] (/Users/darrenjennings/source/repos/vite-sup/node_modules/resolve-from/index.js:46:47)
at app.use (/Users/darrenjennings/source/repos/vite-sup/node_modules/vite/dist/serverPluginModules.js:143:51) code: 'MODULE_NOT_FOUND' }
[vite] Error while resolving node_modules with id "use-swrv":
{ Error: Cannot find module 'use-swrv/package.json'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:668:15)
at resolveFileName (/Users/darrenjennings/source/repos/vite-sup/node_modules/resolve-from/index.js:29:39)
at resolveFrom (/Users/darrenjennings/source/repos/vite-sup/node_modules/resolve-from/index.js:43:9)
at Object.module.exports [as default] (/Users/darrenjennings/source/repos/vite-sup/node_modules/resolve-from/index.js:46:47)
at app.use (/Users/darrenjennings/source/repos/vite-sup/node_modules/vite/dist/serverPluginModules.js:143:51) code: 'MODULE_NOT_FOUND' }```
I tried import like this...
import something from 'https://unpkg.com/swrv@0.3.0/esm/index.js'
got error too
[vite] Error while resolving node_modules with id "https://unpkg.com/swrv@0.3.0/esm/index.js":
{ Error: Cannot find module 'https:/package.json'
workaround for now maybe snowpack... ?
@ais-one to be clear, I'm not importing from unpkg. I am importing from my local node_modules after yarn add swrv
to a new vite project, and then using it here: import useSWRV from 'swrv'
. The unpkg url is just for reference so you can see that the file has relative path imports.
would 0.6.0 help?
fix resolving scoped packages and relative imports inside node_modules (#15) (78ae1b7)