【问题标题】:command npm generates errors related to lifecycle and starting the App命令 npm 生成与生命周期和启动应用程序相关的错误
【发布时间】: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


    【解决方案1】:

    我想正确的命令是npm run start,这是拼写错误,如果继续你会发现构建命令是npm run build

    【讨论】:

    • 我使用 npm run start 但收到同样的错误
    • 我尝试遵循相同的指导方针,它适用于我,在 github.com/macorifice/parcel-project 示例项目中,我在 package.json 中添加了引擎,可能是 npm 或节点版本问题
    • 如果有任何答案解决了您的问题,请考虑通过单击复选标记接受它。这向更广泛的社区表明您已经找到了解决方案,并为回答者和您自己提供了一些声誉。如果答案中仍有任何不清楚的地方,请随时提问。
    猜你喜欢
    • 1970-01-01
    • 2017-12-27
    • 1970-01-01
    • 2019-09-13
    • 1970-01-01
    • 1970-01-01
    • 2020-12-23
    • 1970-01-01
    • 2013-04-06
    相关资源
    最近更新 更多