Following a tutorial I found this chunk of code in a file:
export default require ('knex') ({
client : 'mysql';
connection : {
host : 'localhost',
user : 'root',
password: '',
database : 'graph',
charset : 'utf8',
}
});
This file is being imported in another as :
import Knex from './knex'
When I run the app I get this error
Unexpected token (1:20)
export default knex require ('knex') ({
client : 'mysql';
connection : {
host : 'localhost',
}
})
I want to fix this but I don't understand how require
works when is preceded for export default
.
Thanks!
Your
export default require
is not valid. Try this instead:It exports an objet that you can later import with
import myObj from './myfile'
.