Answer the question
In order to leave comments, you need to log in
How to connect a module installed globally in a JS script?
On my local machine ( Windows ) I installed node.js .
Then I installed the modules with npm install -g redux react-redux . (Here, redux is purely an example. The module can be anything)
Next, I created an index.js script :
import { createStore } from 'redux';
let store = createStore(()=>{}, 0);
Uncaught SyntaxError: Cannot use import statement outside a module
Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension
Answer the question
In order to leave comments, you need to log in
Cannot use import statement outside a module
<script src="script.js" type="module"></script>
When I run the node index.js command in the console, I get an error:
To load an ES module, set"type": "module"
in thepackage.json
or use the .mjs extension
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question