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.

Optimized dependency error

See original GitHub issue

Do NOT ignore this template or your issue will have a very high chance to be closed without comment.

Describe the bug

When I added ant-design-vue, an error occurred.


Dep optimization failed with error:
[vite]: Rollup failed to resolve import "indexof" from "indexof?commonjs-external".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`rollupInputOptions.external`
(node:28953) UnhandledPromiseRejectionWarning: Error: [vite]: Rollup failed to resolve import "indexof" from "indexof?commonjs-external".
This is most likely unintended because it can break your application at runtime.
If you do want to externalize this module explicitly add it to
`rollupInputOptions.external`

I tried adding indexof to rollupInputOptions.external, but this did not work.

At the same time, the project has another error.

import Ant from 'ant-design-vue';

import 'ant-design-vue/dist/antd.css'

When the following two sentences are introduced at the same time, vite will prompt to add ant-design-vue/dist/antd.css to optimizeDeps.include. But after I added it, an error was reported, and the error message is as follows

Dep optimization failed with error:
Entry module cannot be external (node_modules/ant-design-vue/dist/antd.css).

Reproduction

  1. clone https://github.com/anncwb/vite-bug
  2. yarn serve

System Info

  • required vite version:
  • required Operating System:
  • required Node version:
  • Optional:
    • npm/yarn version
    • Installed vue version (from yarn.lock or package-lock.json)
    • Installed @vue/compiler-sfc version

Logs (Optional if provided reproduction)

  1. Run vite or vite build with the --debug flag.
  2. Provide the error log here.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:7

github_iconTop GitHub Comments

3reactions
Ttoucommented, Jan 4, 2021

@yyx990803 60a4708 好像只是把报错改成了报警,真正导致错误的原因似乎是 ant-design-vue 引用了 indexof 而 rollup 处理失败了 iShot2021-01-04 17 40 49

2reactions
evanwillscommented, Mar 27, 2021

Hi @anncwb

I just ran into this problem too. I fixed it (surprisingly) by adding a leading slash to the file path.

e.g. change import 'ant-design-vue/dist/antd.css' to

import '/ant-design-vue/dist/antd.css'

Hopefully, it will help you.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Dependencies error while trying to use country selector in my ...
After I install it in my ubuntu, and I am trying to run the code however I am getting this error : [ERROR]...
Read more >
Dependency optimization - CloudBees Documentation
When dependency optimization is enabled, eMake maintains a dependency information file for each makefile. If a build's dependencies have not changed from ...
Read more >
Dependency Resolution Optimization - ActiveState's Approach
Dependency resolution is at the core of the ActiveState Platform. When you create a project and start adding requirements, we tell you what ......
Read more >
Dependency Injection Not Wiring Up Properly When Optimize ...
I debugged locally and strangely when my Web project is optimized, the DLL that is passed to the AddMvcControllers method is Sitecore.Kernel ...
Read more >
Dependency of optimization error of Algorithm 1 on iteration
Download scientific diagram | Dependency of optimization error of Algorithm 1 on iteration from publication: Improved Exploiting Higher Order Smoothness in ...
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