2
I’m having the following error when trying to run a module in Javascript:
Uncaught Syntaxerror: Unexpected Identifier
- index.html
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Módulos JavaScript</title>
<script src="index.js"></script>
</head>
<body>
<!-- BODY -->
</body>
</html>
- index js.
import nome from './src/config';
console.log(nome);
- src/config.js
const nome = 'ECMAScript 6'
export default nome;
Because the mistake happens?
When running the script the following error appears "GET http://127.0.0.1/modulos/src/config 404 (Not Found)", then add the extension ". js" file the error some, now I wonder if it is possible to run import code without file extension?
– user106463
Works without extension?
– Sam
That’s what I want to know. It works?
– user106463
I think not because the browser will understand that it is a folder
– Sam
The extension that defines what type of file it is, and the browser interprets it differently depending on the extension. No extension is a folder
– Sam