question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unhandled rejection TypeError: Cannot read property 'key' of undefined.

See original GitHub issue

I have a migration set up that worked previously. When I go to run sequelize db:migrate. I get the following error output.

Unhandled rejection TypeError: Cannot read property 'key' of undefined
    at Sequelize.normalizeDataType (/Users/jneal2/Projects/brick-gardens/central-server-api/node_modules/sequelize/lib/sequelize.js:1209:64)
    at /Users/jneal2/Projects/brick-gardens/central-server-api/node_modules/sequelize/lib/query-interface.js:88:37
    at /Users/jneal2/Projects/brick-gardens/central-server-api/node_modules/sequelize/node_modules/lodash/index.js:3395:24
    at /Users/jneal2/Projects/brick-gardens/central-server-api/node_modules/sequelize/node_modules/lodash/index.js:3073:15
    at baseForOwn (/Users/jneal2/Projects/brick-gardens/central-server-api/node_modules/sequelize/node_modules/lodash/index.js:2046:14)
    at Function.<anonymous> (/Users/jneal2/Projects/brick-gardens/central-server-api/node_modules/sequelize/node_modules/lodash/index.js:3394:9)
    at QueryInterface.createTable (/Users/jneal2/Projects/brick-gardens/central-server-api/node_modules/sequelize/lib/query-interface.js:83:24)
    at Object.module.exports.up (/Users/jneal2/Projects/brick-gardens/central-server-api/migrations/.20150714145903-create-satchel.js:7:27)
    at module.exports.redefine.Class._exec (/Users/jneal2/.nvm/versions/node/v0.12.7/lib/node_modules/sequelize-cli/node_modules/umzug/lib/migration.js:49:23)
    at module.exports.redefine.Class.up (/Users/jneal2/.nvm/versions/node/v0.12.7/lib/node_modules/sequelize-cli/node_modules/umzug/lib/migration.js:33:17)
    at null.<anonymous> (/Users/jneal2/.nvm/versions/node/v0.12.7/lib/node_modules/sequelize-cli/node_modules/umzug/index.js:78:28)
    at Object.tapHandler (/Users/jneal2/.nvm/versions/node/v0.12.7/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/finally.js:63:43)
    at Object.tryCatcher (/Users/jneal2/.nvm/versions/node/v0.12.7/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/util.js:26:23)
    at Promise._settlePromiseFromHandler (/Users/jneal2/.nvm/versions/node/v0.12.7/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/promise.js:489:31)
    at Promise._settlePromiseAt (/Users/jneal2/.nvm/versions/node/v0.12.7/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/promise.js:565:18)
    at Promise._settlePromises (/Users/jneal2/.nvm/versions/node/v0.12.7/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/promise.js:681:14)
    at Async._drainQueue (/Users/jneal2/.nvm/versions/node/v0.12.7/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/async.js:123:16)
    at Async._drainQueues (/Users/jneal2/.nvm/versions/node/v0.12.7/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/async.js:133:10)
    at Immediate.Async.drainQueues [as _onImmediate] (/Users/jneal2/.nvm/versions/node/v0.12.7/lib/node_modules/sequelize-cli/node_modules/bluebird/js/main/async.js:15:14)
    at processImmediate [as _immediateCallback] (timers.js:367:17)

I’m using Sequelize 3.3.2, and the CLI version is 3.9.0.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Reactions:1
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

65reactions
DesignByOnyxcommented, Apr 21, 2016

This bit me too. I was wanting to change a column to allow NULL values. I was using the following code:

    queryInterface.changeColumn(
      'myTable',
      'someColumn',
      {
        allowNull: true
      }
    );

… but things did not start working until I specified a type:

    queryInterface.changeColumn(
      'myTable',
      'someColumn',
      {
        type: Sequelize.STRING,
        allowNull: true
      }
    );
7reactions
radglobcommented, Jul 16, 2015

Figured it out. I wasn’t specifying a type for an array.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot Read Property of Undefined in JavaScript - Rollbar
TypeError: Cannot read property of undefined occurs when a property is read or a function is called on an undefined variable.
Read more >
Unhandled Rejection (TypeError): Cannot read property 'data ...
I have solved the problem. So the first issue I came across is that I can't enter a Github user name when creating...
Read more >
How to Prevent the Error: Cannot Read Property '0' of Undefined
A guide on how to prevent the error "cannot Read Property '0' of Undefined", covering techniques such as try, catch, using const over...
Read more >
Uncaught TypeError: Cannot read property of undefined In
Uncaught TypeError: Cannot read property of undefined error occurs in Chrome when you read a property or call a method on an undefined...
Read more >
Resolving the JavaScript Promise Error "TypeError: Cannot ...
TypeError - Cannot read property 'then' of undefined is thrown when the caller is expecting a Promise to be returned and instead receives ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found