-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
目录中只要存在node_modules,无法正常运行 #17903
Labels
duplicate
This issue or pull request already exists
Comments
Start a new pull request in StackBlitz Codeflow. |
I don't think the parent directory should contain node_modules, which would be confusing |
|
Dupcalite of #17467 |
sapphi-red
added
duplicate
This issue or pull request already exists
and removed
pending triage
labels
Aug 20, 2024
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Describe the bug
在项目的上级目录中只要存在node_modules,那么CommonJS 导入的就无法正常解析
1.在项目中,我导入两个包一个是axios一个是dayjs(在其他项目中导入了其他包也是如此,这里为了最小化展示就导入两个包)
2.当上级目录出现node_modules目录的时候,就如下图所示
3.尝试代码一个不变的将其移到上级总没有node_modules的目录下,就正常运行了
4.由于这是目录问题,无法在stackblitz中提供示例
Reproduction
https://stackblitz.com/edit/vitejs-vite-pcpxok?file=index.html&terminal=dev
Steps to reproduce
1.正常的使用vite安装vue-ts :yarn create vite my-vue-app --template vue-ts
2.导入包dayjs: yarn add dayjs
3. 在main.js中使用dayjs: import dayjs from "dayjs"
4. 正常运行项目:yarn dev
5. 到这里就出现问题了
System Info
Used Package Manager
npm
Logs
[vite] connecting...
client:614 [vite] connected.
main.ts:8 Uncaught SyntaxError: The requested module '/node_modules/dayjs/dayjs.min.js?v=4c94d2c5' does not provide an export named 'default' (at main.ts:8:8)
Validations
The text was updated successfully, but these errors were encountered: