I have a js file called project specific js.js and in that file I want to import another js file for general js called logic.js in the js folder
import 'js/logic.js';
in devtools when I run the html that imports project specific js i get
Uncaught SyntaxError: Cannot use import statement outside a module
Issue fixed. It turns out because I wasn't running via localhost, for some reason you cant import other js files except modules like react. Now I am running via localhost, and the type
attribute is set to "module"
in the script tag that imports projectSpecificJs.js
, so <script type="module" src="projectSpeceficJs.js></script>
.