我正在尝试部署在节点中创建的其余 api,并在渲染中使用打字稿。但是,在部署时我收到以下日志:
==> Exited with status 127
==> Common ways to troubleshoot your deploy: https://docs.render.com/troubleshooting-deploys
==> Using Node version 20.15.1 (default)
==> Docs on specifying a Node version: https://render.com/docs/node-version
==> Using Bun version 1.1.0 (default)
==> Docs on specifying a bun version: https://render.com/docs/bun-version
==> Running 'npm run dev'
> [email protected] dev
> nodemon ./src/app.ts
sh: 1: nodemon: not found
部署时我放入根目录:src。在构建命令中:npm install。并在启动命令中:
npm run dev
这是我项目的package.json
{
"name": "drivesafe-backend",
"version": "1.0.0",
"main": "index.js",
"scripts": {
"dev": "nodemon ./src/app.ts"
},
"keywords": [],
"author": "",
"license": "ISC",
"description": "",
"devDependencies": {
"@types/bcryptjs": "^2.4.6",
"@types/cors": "^2.8.17",
"@types/dotenv": "^6.1.1",
"@types/express": "^4.17.21",
"@types/jsonwebtoken": "^9.0.7",
"@types/multer": "^1.4.12",
"@types/mysql2": "github:types/mysql2",
"@types/sequelize": "^4.28.20"
},
"dependencies": {
"bcryptjs": "^2.4.3",
"cors": "^2.8.5",
"dotenv": "^16.4.5",
"express": "^4.21.0",
"jsonwebtoken": "^9.0.2",
"multer": "^1.4.5-lts.1",
"mysql2": "^3.11.3",
"sequelize": "^6.37.3"
}
}
我尝试将其放入构建命令中:
npm install npm install typescript -g npm install i ts-node -g npm install i nodemon -g tsc —init npm init -y npm i express cors dotenv multer mysql2 npm i @types/express @types/cors @types/dotenv @types/multer -D npm i --save-dev types/mysql2# npm i bcryptjs npm i jsonwebtoken
但是,当我这样做时,我遇到了另一个问题:
==> Docs on specifying a Node version: https://render.com/docs/node-version
==> Using Bun version 1.1.0 (default)
==> Docs on specifying a bun version: https://render.com/docs/bun-version
==> Running build command 'npm install npm install typescript -g npm install i ts-node -g npm install i nodemon -g tsc —init npm init -y npm i express cors dotenv multer mysql2 npm i @types/express @types/cors @types/dotenv @types/multer -D npm i --save-dev types/mysql2# npm i bcryptjs npm i jsonwebtoken'...
npm error arg Argument starts with non-ascii dash, this is probably invalid: —init
npm error code EINVALIDTAGNAME
npm error Invalid tag name "—init" of package "—init": Tags may not have any characters that encodeURIComponent encodes.
npm error A complete log of this run can be found in: /opt/render/.cache/_logs/2024-10-06T17_05_36_663Z-debug-0.log
==> Build failed 😞
==> Common ways to troubleshoot your deploy: https://docs.render.com/troubleshooting-deploys```
您的第一个问题是
nodemon
未列为 devDependency
。
您应该使用 npm install --save-dev nodemon
安装它。然后它将可以与您的其余依赖项一起使用。
在第二次尝试中,命令的格式无效。您不能仅将多个安装命令添加到由空格分隔的一行中。尝试使用单个安装命令列出多个依赖项,或使用
&&
分隔多个命令。