glob import doesn't search under node_modules
See original GitHub issueDescribe the bug
A lot of npm packages support loading different locales on the fly(like dayjs)
But when do import.meta.glob('/node_modules/some-package/locale/*.js
will return empty object
So now I need to move all the locale js outside node_modules, which causes a lot of lining issue
It seems like someone actively disabled it https://github.com/vitejs/vite/commit/8b3d0ea41265870b9b0741bde3a31bde81078277
But I don’t think it’s the intended behaviour, ref: https://github.com/vitejs/vite/issues/1985#issuecomment-778269015
Doc also doesn’t specify this behaviour
System Info
System:
OS: macOS 11.2.3
CPU: (8) x64 Intel(R) Core(TM) i5-1038NG7 CPU @ 2.00GHz
Memory: 127.06 MB / 16.00 GB
Shell: 5.8 - /bin/zsh
Binaries:
Node: 14.17.0 - ~/.nvm/versions/node/v14.17.0/bin/node
Yarn: 1.22.11 - /usr/local/bin/yarn
npm: 6.14.13 - ~/.nvm/versions/node/v14.17.0/bin/npm
Browsers:
Chrome: 96.0.4664.110
Safari: 14.0.3
npmPackages:
@vitejs/plugin-react: 1.1.3 => 1.1.3
vite: 2.7.10 => 2.7.10
Used Package Manager
yarn
Logs
No response
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a Vite issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/vue-next instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion or join our Discord Chat Server.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How do I import global modules in Node? I get "Error
All it does is create a local node_modules folder and then create a symlink express -> [global directory]/node_modules/express which can then be resolved...
Read more >node_modules folder is always marked as "library root" with ...
So I used to manually exclude 99% of node_modules and leave only a few indexed by the IDE to do that. Now though,...
Read more >glob - npm
Start using glob in your project by running `npm i glob`. ... There is no way at this time to continue a glob...
Read more >TSConfig Reference - Docs on every TSConfig option
If a glob pattern doesn't include a file extension, then only files with supported ... by exclude can still become part of your...
Read more >Modules: Packages | Node.js v19.3.0 Documentation
If a package.json file does not have a "type" field, .js files are treated ... the entry point of a package when imported...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Seems to be working for me for Vite 2.8.2 and above. Closing as fixed by #6056. @pecliu Please provide a repro if this still happens for you in the latest version. Thanks!
I think this PR #6056 fixes this issue.