本地主机无法显示在 javascript 中创建的输出映射

问题描述

来自 openlayers 的这个研讨会文档

https://openlayers.org/workshop/en/basics/

包含一个示例。我正在尝试让它运行,但尽管两者都

npm start
npm run build 

运行成功,但是当我访问本地主机时“请查看附件”

http://localhost:3000/

http://localhost:1234/

什么都不会显示。 请告诉我如何解决这个问题

package.json

    {
  "name": "app6","version": "1.0.0","description": "","main": "index.js","scripts": {
    "test": "echo \"Error: no test specified\" && exit 1","start": "parcel index.html","build": "parcel build --public-url . index.html"
  },"author": "","license": "ISC","dependencies": {
    "ol": "^6.5.0"
  },"devDependencies": {
    "parcel-bundler": "^1.12.5"

} }

图片

enter image description here

解决方法

不要停止这个过程。

npm start

然后让服务器运行(nicht abbrechen)并转到:

http://localhost:1234/

如果你运行:

npm run build 

您必须将构建文件夹复制到服务器才能运行。