I want to use es6 modules and I installed babel plugin (es2015-modules-amd) for them. But what I write in the module is not imported to the main file, console errors: " Uncaught ReferenceError: define is not defined" at the first attempt to import anything. Same thing has happened when I tried to use common.js with those require statements, console just has pointed, the error and that require is not defined too. What is it?
3 Answers
i had to install
npm i -D @babel/plugin-transform-modules-amd
and use .babelrc
file
{
"plugins": [
"transform-es2015-modules-amd"
]
}
Another method solved my problem when it came up "define is not defined" error from babel:
npm install --save-dev browserify
browserify input.js > output.js
Although it's browserify
easily solved the problem.
define
function.