【发布时间】:2021-06-14 15:33:35
【问题描述】:
我正在学习 openlayers 和 javascript。在下面的教程中
https://openlayers.org/en/latest/doc/tutorials/bundle.html
它展示了一个简单的带有 javascript 的 openlayers 项目。我按照教程但是命令
npm start
npm run start
给我以下错误:
(venv) M:\openlayers\projects\app1>npm start
> app1@1.0.0 start M:\openlayers\projects\app1
> parcel index.html
Der Befehl "parcel" ist entweder falsch geschrieben oder
konnte nicht gefunden werden.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! app1@1.0.0 start: `parcel index.html`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the app1@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Amr.Bakri\AppData\Roaming\npm-cache\_logs\2021-03-17T09_48_09_536Z-debug.log
index.javascript:
import 'ol/ol.css';
import {Map, View} from 'ol';
import TileLayer from 'ol/layer/Tile';
import OSM from 'ol/source/OSM';
const map = new Map({
target: 'map',
layers: [
new TileLayer({
source: new OSM()
})
],
view: new View({
center: [0, 0],
zoom: 0
})
});
index.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Using Parcel with OpenLayers</title>
<style>
#map {
width: 400px;
height: 250px;
}
</style>
</head>
<body>
<div id="map"></div>
<script src="./index.js"></script>
</body>
</html>
【问题讨论】:
标签: javascript npm openlayers npm-install npm-start