Node.js API服务器--无法构建。

问题描述 投票:0回答:1

我在创建Node Js API应用程序时遇到了困难。

下面是我的package.json文件的样子。

{
    "name": "node-mongo-registration-login-api",
    "version": "1.0.0",
    "description": "NodeJS + MongoDB API for User Management, Authentication and Registration",
    "main": "server.js",
    "license": "MIT",
    "scripts": {
        "start": "node ./server.js",
        "start-dev": "nodemon ./server.js",
        "build": "react-scripts build"
    },
    "dependencies": {
        "bcryptjs": "^2.4.3",
        "body-parser": "^1.19.0",
        "cors": "^2.8.5",
        "express": "^4.17.1",
        "express-jwt": "^5.3.3",
        "jsonwebtoken": "^8.5.1",
        "mongodb": "^3.5.6",
        "mongoose": "^5.9.10",
        "react-scripts": "^3.4.1",
        "rootpath": "^0.1.2"
    },
    "devDependencies": {
        "nodemon": "^2.0.3"
    }
}

当我运行 npm运行构建它给出了以下错误。

Could not find a required file.
  Name: index.html
  Searched in: C:\Users\Tejas\Desktop\React\Templates\node-mongo-registration-login-api-master\public
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build 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\Tejas\AppData\Roaming\npm-cache\_logs\2020-06-15T10_12_13_343Z-debug.log

我不知道为什么在一个不需要UI的服务器应用程序中需要index.html。

node.js npm nodemon
1个回答
1
投票

如果你只是实现API而没有react应用程序,你不需要构建它。npm run start 来启动你的服务器。

© www.soinside.com 2019 - 2024. All rights reserved.