下面的文字是我从日志请求中得到的结果。
web[2413]: > [email protected] start
web[2413]: > nodemon index.ts
web[2479]: sh: line 1: nodemon: command not found
web[2484]: > [email protected] start
web[2484]: > nodemon index.ts
web[2502]: sh: line 1: nodemon: command not found
这是package.json代码。我正在使用 TypeScript。
{
"name": "backend",
"version": "1.0.0",
"description": "",
"main": "index.ts",
"scripts": {
"start": "nodemon index.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"dependencies": {
"@aws-sdk/client-s3": "^3.569.0",
"@aws-sdk/s3-request-presigner": "^3.569.0",
"@prisma/client": "^5.13.0",
"bcryptjs": "^2.4.3",
"cookie-parser": "^1.4.6",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.19.2",
"jsonwebtoken": "^9.0.2",
"multer": "^1.4.5-lts.1",
"prisma": "^5.13.0",
"sharp": "^0.33.3"
},
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/cookie-parser": "^1.4.7",
"@types/cors": "^2.8.17",
"@types/express": "^4.17.21",
"@types/jsonwebtoken": "^9.0.6",
"@types/multer": "^1.4.11",
"@types/node": "^20.12.7",
"typescript": "^5.4.5"
}
}
index.ts代码
import express, { Express, Request, Response } from "express";
import cors from "cors";
import dotenv from "dotenv";
import postRouter from "./routes/post";
import authRouter from "./routes/auth";
import userRouter from "./routes/user";
import messageRouter from "./routes/message";
import chatRouter from "./routes/chat";
import cookieParser from "cookie-parser";
dotenv.config();
const app: Express = express();
const PORT = process.env.PORT || 8800; // process.env.PORT === 5000
app.use(cors({ origin: process.env.CLIENT_URL, credentials: true }));
app.use(express.json());
app.use(cookieParser());
app.use("/api/posts", postRouter);
app.use("/api/auth", authRouter);
app.use("/api/users", userRouter);
app.use("/api/chats", chatRouter);
app.use("/api/messages", messageRouter);
app.listen(PORT, () => {
console.log(`[server]: Server is running at <https://localhost>:${PORT}`);
});
此警告消息出现了 3 次。
无法构建最佳的 types_hash,您应该增加 types_hash_max_size: 1024 或 types_hash_bucket_size: 64;忽略 types_hash_bucket_size
这是一条错误消息。!!!
1 连接到上游时 connect() 失败(111:连接被拒绝),客户端:(省略自身),服务器:,请求:“GET / HTTP/1.1”,上游:“http://127.0.0.1:8080/ ”,主持人:(省略)
1 连接到上游时 connect() 失败(111:连接被拒绝),客户端:(省略自身),服务器:,请求:“GET /favicon.ico HTTP/1.1”,上游:“http://127.0.0.1 :8080/favicon.ico", 主机: (省略本身), 推荐人: (省略本身)
服务角色和EC2实例配置文件似乎设置得很好。
压缩文件时,我尝试包含和排除node_modules文件夹。
端口号有问题吗? 任何帮助将不胜感激。我的时间不多了。TT
您的 package.json 中缺少
nodemon
作为依赖项:https://www.npmjs.com/package/nodemon
"dependencies": {
...
"nodemon": "^3.1.0"
}