Let me try to explain...
I have an utils.js file which does not work:
import dayjs from 'dayjs'; //https://github.com/iamkun/dayjs
exports.utils = (function() {
someDateFunction() {
...some dayjs function calls ....
}
})();
(As stated by an answering person thta it needs to be module.exports - well it does not matter. I have other source files where it works either way - with or without prenoted module..)
When declaring the first line with the import statement vue-cli seems to properly compile. no error is shown. Running in the browser shows:
Uncaught ReferenceError: exports is not defined
at eval (utils.js?2f14:3)
at Module../src/assets/js/utils.js (app.js:1541)
at __webpack_require__ (app.js:849)
at fn (app.js:151)
...
It do include/import this utils.jsfile by noting
const { utils } = require("@/assets/js/utils.js");
Why is it not allowed to import in the file?
If you need informations about versions I run let me know and also let me know what commands will show the demanded information (running on macos).
I already searched the web. the problem seems to be known in the past. There is some clues solving it with typescript or vue js.
Nothing works for me. I must not be the first one stumbling over issues like that, am I? Any help appreciated.
References:
https://stackoverflow.com/a/55334703/845117
My dependencies in package.json
"dependencies": {
"axios": "^0.21.1",
"bootstrap": "^4.5.3",
"bootstrap-vue": "^2.18.0",
"core-js": "^3.6.5",
"cropperjs": "^1.5.9",
"dayjs": "^1.9.6",
"vue": "^2.6.12"
},