数据库迁移-TypeError:无法读取未定义的属性“切片”

时间:2019-10-12 04:29:34

标签: node.js heroku npm database-migration

尝试将数据库表迁移到heroku,并遇到以下错误。 当我运行

heroku pg:credentials:url

我可以获取连接URL。 但是当我尝试运行脚本

"env SSL=true DATABASE_URL=postgres://azgtqialharhur:647e8109bcabdeda90c00f6ca961e603f01529177d2ddefb4f1cf9bf47552653@ec2-54-243-44-102.compute-1.amazonaws.com:5432/df6c2t2q7bb1s4 npm run migrate"

我遇到以下错误:


> fit-tracker@1.0.0 migrate:production C:\Users\User\Desktop\project\fit-tracker-database
> env SSL=true DATABASE_URL=postgres://azgtqialharhur:647e8109bcabdeda90c00f6ca961e603f01529177d2ddefb4f1cf9bf47552653@ec2-54-243-44-102.compute-1.amazonaws.com:5432/df6c2t2q7bb1s4 npm run migrate


> fit-tracker@1.0.0 migrate C:\Users\User\Desktop\project\fit-tracker-database
> postgrator --config postgrator-config.js

Password: 
C:\Users\User\Desktop\project\fit-tracker-database\node_modules\postgrator-cli\postgrator-cli.js:187
        rl.history = rl.history.slice(1);
                                ^

TypeError: Cannot read property 'slice' of undefined
    at rl.question (C:\Users\User\Desktop\project\fit-tracker-database\node_modules\postgrator-cli\postgrator-cli.js:187:33)
    at Interface._onLine (readline.js:288:5)
    at Interface._normalWrite (readline.js:433:12)
    at Socket.ondata (readline.js:149:10)
    at Socket.emit (events.js:189:13)
    at addChunk (_stream_readable.js:284:12)
    at readableAddChunk (_stream_readable.js:265:11)
    at Socket.Readable.push (_stream_readable.js:220:10)
    at Pipe.onStreamRead [as onread] (internal/stream_base_commons.js:94:17)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fit-tracker@1.0.0 migrate: `postgrator --config postgrator-config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fit-tracker@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!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-10-12T04_14_43_701Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fit-tracker@1.0.0 migrate:production: `env SSL=true DATABASE_URL=postgres://azgtqialharhur:647e8109bcabdeda90c00f6ca961e603f01529177d2ddefb4f1cf9bf47552653@ec2-54-243-44-102.compute-1.amazonaws.com:5432/df6c2t2q7bb1s4 npm run migrate`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fit-tracker@1.0.0 migrate:production 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!     C:\Users\User\AppData\Roaming\npm-cache\_logs\2019-10-12T04_14_43_752Z-debug.log

任何帮助将不胜感激。

1 个答案:

答案 0 :(得分:0)

我在各种项目中都看到了这个错误。我已经看到通过安装早期版本的postgrator-cli软件包可以解决此问题。

我看到的另一种解决方案是使用yarn而不是npm。