i am a newbie trying to figure out how to use node packages to my web-dev workflow. For example i am trying to test the axios ajax library.
I thought this should be fairly easy but it's driving me crazy.
So in a folder i have an index.html and an index.js file.
I have run "npm init -y" to create a package.json file and then "npm install axios --save". The package has been installed in the node_modules folder and as a dependency in the package.json file.
Now how should i use the library in my index.js file?
I am trying the following in my index.js file (1st line)
import axios from "axios";
In chrome i get: "Uncaught SyntaxError: Unexpected identifier" In firefox: "SyntaxError: import declarations may only appear at top level of a module"
Trying to link the index.js file with type="module" (as i saw in some other topics) didn't help either. I am just getting a bit different errors.
What am i missing?