Currently, I am delving into the world of OpenLayers and JavaScript. I came across a helpful tutorial that provides step-by-step guidance on creating a simple OpenLayers project using JavaScript. I followed the instructions diligently but encountered an error when trying to run the command:
npm start
npm run start
The error message I received is as follows:
(venv) M:\openlayers\projects\app1>npm start
> <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d1b0a1a1e091e0ffe1ffe1">[email protected]</a> 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! <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1c7d6c6c2d5c2d322c322c">[email protected]</a> start: `parcel index.html`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the <a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="a4c5d4d495e4958a948a94">[email protected]</a> 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>