I know that maybe I get some negative votes. but it is not a big problem.I have no other option. I tried too much to send data to my node.js server without using form. I used axios. but my main.js doesn't know axios. i installed it
npm install axios
I imported it
import axios from ('axios')
but I got the error ( unexpected Identifier)
after that I tried require
var axios = require ('axios')
but I got the error ( require is not defined)
I installed browserify
npm install broweserify
after that I bundled it with this code
browserify main.js -o bundle.js
but the same error still remains
require is not defined.
has somebody a solution.
APPRECIATED
Your import syntax seems to be wrong, maybe that is the reason. You don't need the parantheses in import:
import axios from 'axios'
I'm also guessing that you are running this code in front-end and not in node.js. that's probably why you get 'require is not defined' error. (see: https://stackoverflow.com/a/9901097/7228779 )
It also looks like you misspelled browserify (not broweserify
) in your install command, so that might be an issue too.