命令 npm 生成与生命周期和启动应用程序相关的错误

问题描述

我正在学习 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

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...