Vite Rollup Error: Cannot Resolve 'lodash.throttle' Import
This error occurs because your code uses the 'lodash.throttle' library, but Rollup cannot find it. To fix this, add 'lodash.throttle' to the 'build.rollupOptions.external' configuration.
In your 'vite.config.js' file, locate the 'build.rollupOptions' configuration. If it doesn't exist, add it. Then, add an 'external' property and include 'lodash.throttle' in the array, like this:
export default defineConfig({
// other config options...
build: {
rollupOptions: {
external: ['lodash.throttle']
}
}
})
Save the file and restart your application. This should fix the error.
原文地址: https://www.cveoy.top/t/topic/qpDo 著作权归作者所有。请勿转载和采集!