简体   繁体   English

Parcel Bundler:本地主机上一切正常,但 Dist 上的 index.html 显示错误

[英]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 脚本连接代码

My all folders list我的所有文件夹列表

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.

相关问题 @parcel/core: 无法解析“index.html”得到这个错误 - @parcel/core: Failed to resolve 'index.html' Getting this error 错误:ENOENT:没有这样的文件或目录,打开 'dist\browser\index.html' - Error: ENOENT: no such file or directory, open 'dist\browser\index.html' 是否可以装饰包裹捆绑器 dist 文件夹? - Is it possible to decorate parcel bundler dist folder? npm run dev 和 parcel index.html 的区别 - Difference between npm run dev and parcel index.html 使用“parcel index.html”后外部 .js 不起作用 - external .js not working after using “parcel index.html” 未捕获到的SyntaxError:dist / index.html中的意外令牌&lt; - Uncaught SyntaxError: Unexpected token < in dist/index.html Webpack 从入口文件导入,在 dist/index.html 中不可用 - Webpack imports from entry file, not available in dist/index.html Github 实时预览 readme 而不是 /dist/ 文件夹中的 index.html - Github live previews readme instead of index.html in the /dist/ folder 通过启动外部文件 index.html I 忽略主文件,服务器在包裹中运行错误,但它也不起作用(构建失败) - Server running error in parcel by starting the external file index.html I Ignoring the main but it also doesn't work(Build Failed) 通过localhost / myproject / index.html访问localhost:3000 - Access localhost:3000 through localhost/myproject/index.html
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM