我正在做一个NestJS项目。我正试图启动项目,但我得到错误:dotenv: command not found
在终端。我已经检查了包裹。json和我可以看到dotenv安装。此外,我试图安装dotenv与Yarn,但我仍然得到相同的错误。
package.json中的依赖:
"dependencies": {
"@nestjs/common": "^8.1.1",
"@nestjs/config": "1.0.2",
"@nestjs/core": "^8.1.1",
"@nestjs/jwt": "^8.0.0",
"@nestjs/passport": "^8.0.1",
"@nestjs/platform-express": "^8.1.1",
"@nestjs/swagger": "^5.1.2",
"@prisma/client": "3.3.0",
"bcrypt": "^5.0.1",
"class-transformer": "^0.4.0",
"class-validator": "^0.13.1",
-> "dotenv": "^10.0.0",
"express-rate-limit": "^5.5.0",
"helmet": "^4.6.0",
"nanoid": "^3.1.30",
"nodemailer": "^6.7.0",
"passport": "^0.5.0",
"passport-jwt": "^4.0.0",
"reflect-metadata": "^0.1.12",
"request-ip": "^2.1.3",
"rimraf": "^3.0.2",
"rxjs": "^7.4.0",
"swagger-ui-express": "^4.1.4"
},
我正在使用的起始脚本:
"start:dev": "dotenv -e env/local.env -- nest start --watch",
我找到了解决方案,它可能会帮助别人。要在终端中运行dotenv命令,我们需要dotenv-cli。用yarn add dotenv-cli
安装dotenv-cli解决了我的问题。