question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

glob import doesn't search under node_modules

See original GitHub issue

Describe 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

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
bluwycommented, Feb 19, 2022

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!

1reaction
ygj6commented, Jan 13, 2022

I think this PR #6056 fixes this issue.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found