出于某种原因,在尝试部署到 heroku 时,我不断收到此错误。
sh: 1: postgrator: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! noteful-server@1.0.0 migrate: `postgrator --config postgrator-config.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the noteful-server@1.0.0 migrate 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! /app/.npm/_logs/2021-01-05T20_30_12_803Z-debug.log
与我发现的另一个错误 here 非常相似。
不同之处在于我确实在依赖项中有 postgrator,所以这不是错误的原因。
这是我的 package.json:
{
"name": "noteful-server",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node src/server.js",
"dev": "nodemon src/server.js",
"migrate": "postgrator --config postgrator-config.js",
"migrate:production": "heroku run npm run migrate",
"deploy": "git push heroku main",
"postdeploy": "npm run migrate:production"
},
"keywords": [],
"author": "Zackry Broodie-Stewart",
"license": "MIT",
"dependencies": {
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"helmet": "^4.3.1",
"knex": "^0.21.15",
"morgan": "^1.10.0",
"node": "^15.4.0",
"pg": "^8.5.1",
"postgrator-cli": "^4.0.0",
"winston": "^3.3.3",
"xss": "^1.0.8"
},
"devDependencies": {
"nodemon": "^2.0.6"
}
}