问题描述
我正在学习 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>
解决方法
我想正确的命令是 npm run start
,这是一个拼写错误,如果你继续你会发现构建命令是 npm run build