【问题标题】:How do I clear npm errors and get my port to run?如何清除 npm 错误并让我的端口运行?
【发布时间】:2021-12-03 21:00:12
【问题描述】:

我正在尝试学习如何创建 API,但在尝试运行 npm run start 时不断出错。

{
  "name": "climate-change-api",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start":"nodemon index.js"
  },
  "author": "Norbert Ogutu",
  "license": "ISC",
  "dependencies": {
    "axios": "^0.23.0",
    "cheerio": "^1.0.0-rc.10",
    "express": "^4.17.1"
  }
}

index.js

const PORT = 8000
const express = require('express')
const axios = require('axios').default
const cheerio = require('cheerio')

const app = express()

app.listen(PORT,() => console.log(`server running on PORT ${PORT}`))

这些是错误:

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! climate-change-api@1.0.0 start: `nodemon index.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the climate-change-api@1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\THE OGUTUS\AppData\Roaming\npm-cache\_logs\2021-10-15T16_37_45_680Z-debug.log

【问题讨论】:

  • 引用的日志文件中有什么内容?

标签: javascript npm nodemon


【解决方案1】:

由于引用的 index.html 除了引用已安装的库之外并没有做太多...而且您确实将这些库列为依赖项...我想知道您是否忘记运行npm install(简称npm i ) 来安装这些依赖项?

另外,由于您未能在依赖项中包含 Nodemon,您是否可能忘记了npm i nodemon

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2022-01-13
    • 2021-10-24
    • 2021-05-03
    • 1970-01-01
    • 2015-01-30
    • 2018-07-21
    • 1970-01-01
    相关资源
    最近更新 更多