Node.js API 服务器 - 无法构建
Node.js API Server - Unable to build
我在构建我的 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 运行 build 时,出现以下错误:
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! node-mongo-registration-login-api@1.0.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-mongo-registration-login-api@1.0.0 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\_logs20-06-15T10_12_13_343Z-debug.log
我不确定为什么在不需要 UI 的服务器应用程序中需要 index.html。
如果您只是实施 API 并且没有 React 应用程序,则不需要构建它。使用 npm run start
启动您的服务器。
我在构建我的 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 运行 build 时,出现以下错误:
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! node-mongo-registration-login-api@1.0.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-mongo-registration-login-api@1.0.0 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\_logs20-06-15T10_12_13_343Z-debug.log
我不确定为什么在不需要 UI 的服务器应用程序中需要 index.html。
如果您只是实施 API 并且没有 React 应用程序,则不需要构建它。使用 npm run start
启动您的服务器。