[英]Parcel Bundler: Everything is okay on localhost but The index.html on Dist is showing Error
I am learning Parcel and trying to bundle a index.html connected with index.js .我正在学习 Parcel 并尝试捆绑与index.js连接的index.html 。 Everything is okay on the parcel
localhost:1234
but in the dist folder when I open the index.html the app is not working.在包裹
localhost:1234
上一切正常,但在 dist 文件夹中,当我打开index.html时,应用程序无法正常工作。
Note: I know that the problem is caused from using import in my index.js注意:我知道问题是由于在我的 index.js 中使用 import 引起的
My package.json File -我的package.json文件 -
{
"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我的 index.html 脚本连接代码
importing redditapi.js in index.js(check the all folder list image)在 index.js 中导入 redditapi.js(检查所有文件夹列表图像)
The error I am getting when I try to use the APP on index.html from dist folder当我尝试在 dist 文件夹中的 index.html 上使用 APP 时出现错误
The problem is fixed.问题已解决。 The import should not include from.
导入不应包括来自。 It should be import 'index';
它应该是 import 'index'; Thank you.
谢谢你。 Everything was fixed after my NPM run build command.
在我的 NPM 运行构建命令后,一切都得到了修复。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.