I am learning Parcel and trying to bundle a index.html connected with index.js. Everything is okay on the parcel localhost:1234
but in the dist folder when I open the index.html the app is not working.
Note: I know that the problem is caused from using import in my index.js
My package.json File -
{
"name": "reddit",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"devDependencies": {
"@babel/core": "^7.10.4",
"cssnano": "^4.1.10"
},
"description": ""
}
My index.html code for script connect
importing redditapi.js in index.js(check the all folder list image)
The error I am getting when I try to use the APP on index.html from dist folder
The problem is fixed. The import should not include from. It should be import 'index'; Thank you. Everything was fixed after my NPM run build command.