问题
Error:
$ heroku run npm run migrate
Running npm run migrate on ⬢ shelly-moth-73910... up, run.3979 (Free)
> noteful-app-server@1.0.0 migrate /app
> postgrator --config postgrator-config.js
sh: 1: postgrator: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! noteful-app-server@1.0.0 migrate: `postgrator --config postgrator-config.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the noteful-app-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/2020-09-06T07_52_36_217Z-debug.log
postgrator-cli version 4.0.0 is installed on repo, running npm list postgrator-cli
tells me that. But after I push to heroku it's as though postgrator doesn't exist. heroku run npm install postgrator-cli
and other such commands don't change, and heroku run npm list postgrator-cli
returns:
$ heroku run npm list postgrator-cli
Running npm list postgrator-cli on ⬢ rocky-garden-73910... up, run.7024 (Free)
noteful-app-server@1.0.0 /app
`-- (empty)
Here's my postgrator-config.js
require('dotenv').config();
module.exports = {
'migrationsDirectory': 'migrations',
'driver': 'pg',
'connectionString':
process.env.NODE_ENV === 'test'
? process.env.TEST_DATABASE_URL
: process.env.DATABASE_URL,
'ssl': !!process.env.SSL,
};
Procfile contains web: node src/server.js
回答1:
I just had the same error.
In my package.json
I found that it was in my "devDependencies"
, not my "dependencies"
.
When I first installed it, I ran npm i postgrator-cli -D
, making it a development dependency. When I tried installing it again without the -D
it didn't do anything, so I deleted it from my package.json
.
Then, I ran npm i postgrator-cli
and checked my package.json
and found that it was in my dependencies
. I git added, committed, and pushed to heroku and then I ran heroku run npm run migrate
- it worked!
来源:https://stackoverflow.com/questions/63761995/postgrator-not-found-while-migrating-postgresql-database