I'm getting the error from the title in my Vue app with Vite. I seem to have tried everything that I could find online but nothing really seems to work in my case.
The problem started when I installed aws-sdk
to connect to my linode bucket storage, and importing it like import aws from 'aws-sdk'
.
I tried almost everything from this issue, and quite a few variants from that in vite.config.js that I found elsewhere.
When using the following in my vite.config.js it works in dev:
define: {
global: "window",
},
But gives me the following error in prod:
[vite]: Rollup failed to resolve import "aws-sdk" from "/var/www/html/kwigy/src/linode.js".
[...]
If you do want to externalize this module explicitly add it to
`build.rollupOptions.external`
[...]
And that doesn't seem to be a good solution anyway according to what I found online.
Adding a script to the tag or making a file that imports the said script in main.js
also works in dev but gives the same error in prod.
I also tried to install requirejs, to use it as const aws = require('aws-sdk')
but I have to admit I do not really understand how to configure that from the docs.
Does anybody have a solution to my problem? I have been stuck for a full day on this now.