0
votes

I have 2 files script.js and newFunction.js.

------ script.js -------

import {pi} from `./newFunction`

console.log(pi);

------ newFunction.js --------

export const pi = 3.141592653;

in the second I am creating variable pi and in first exporting it, but the problem is when I run this gives me an error

SyntaxError: Cannot use import statement outside a module

So how can I fix it?

2

2 Answers

0
votes

Check the code below

<script src="./script.js" type="module"></script>

Refer the link here https://www.freecodecamp.org/forum/t/why-import-in-js-not-working/328947/12

0
votes
module.exports = {
    data: function() {
        return { }
    },
    components: {  'window': 'url:./window.vue' },
}

import component through path in componet ,and you need http-vue-load fist。