Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot read property 'split' of null error #1134

Closed
demisx opened this issue Jan 12, 2016 · 7 comments · Fixed by #2905
Closed

Cannot read property 'split' of null error #1134

demisx opened this issue Jan 12, 2016 · 7 comments · Fixed by #2905
Assignees

Comments

@demisx
Copy link

demisx commented Jan 12, 2016

$ knex -V
Knex CLI version:  0.9.0
Local Knex version:  0.9.0

Running knex migrate:make test produces this error:

$ knex migrate:make test
/usr/local/lib/node_modules/knex/lib/bin/cli.js:104
      var ext = (argv.x || env.configPath.split('.').pop()).toLowerCase();
                                         ^
TypeError: Cannot read property 'split' of null
    at Command.<anonymous> (/usr/local/lib/node_modules/knex/lib/bin/cli.js:104:42)
    at Command.listener (/usr/local/lib/node_modules/knex/node_modules/commander/index.js:301:8)
    at emitTwo (events.js:87:13)
    at Command.emit (events.js:172:7)
    at Command.parseArgs (/usr/local/lib/node_modules/knex/node_modules/commander/index.js:610:12)
    at Command.parse (/usr/local/lib/node_modules/knex/node_modules/commander/index.js:458:21)
    at Liftoff.invoke (/usr/local/lib/node_modules/knex/lib/bin/cli.js:166:13)
    at Liftoff.launch (/usr/local/lib/node_modules/knex/node_modules/liftoff/index.js:163:8)
    at Object.<anonymous> (/usr/local/lib/node_modules/knex/lib/bin/cli.js:186:5)
    at Module._compile (module.js:398:26)
    at Object.Module._extensions..js (module.js:405:10)
    at Module.load (module.js:344:32)
    at Function.Module._load (module.js:301:12)
    at Function.Module.runMain (module.js:430:10)
    at startup (node.js:141:18)
    at node.js:1003:3
@elhigu
Copy link
Member

elhigu commented Jan 15, 2016

Can you show your knexfile too? Sounds like the migration path is set wrong there.

@demisx
Copy link
Author

demisx commented Jan 15, 2016

Here it is:

module.exports = {
  development: {
    client: 'pg',
    connection: {
      database: 'data-api-dev',
      user:     '',
      password: ''
    },
    migrations: {
      tableName: 'knex_migrations'
    },
    debug: true
  },

  test: {
    client: 'pg',
    connection: {
      database: 'data-api-test',
      user:     '',
      password: 'password'
    },
    migrations: {
      tableName: 'knex_migrations'
    }
  },

  staging: {
    client: 'pg',
    connection: {
      database: 'data-api-stg',
      user:     '',
      password: 'password'
    },
    pool: {
      min: 2,
      max: 10
    },
    migrations: {
      tableName: 'knex_migrations'
    }
  },

  production: {
    client: 'pg',
    connection: {
      database: 'data-api-prod',
      user:     '',
      password: 'password'
    },
    pool: {
      min: 2,
      max: 10
    },
    migrations: {
      tableName: 'knex_migrations'
    }
  }
};

@s2t2
Copy link

s2t2 commented Apr 11, 2016

I was getting this error when running knex migrate:make create_robots. It stopped once I specified the location of the knexfile knex migrate:make create_robots --knexfile db/config.js.

@NathanKleekamp
Copy link

Hi @s2t2 , what does the directory path look like in your knexfile? Is it relative to the knexfile you specified with the cli flag? Or is it from the project root where you're running the knex migrate command?

I've tried specifying a different knexfile path by running npm run knex migrate:make test_migration --knexfile path/to/knexfile.js, but I'm still getting the "Cannot read property 'split' of null" error.

If I leave the knexfile.js in the default location, everything works as expected, fwiw.

Thanks a ton! -Nathan

@s2t2
Copy link

s2t2 commented May 5, 2016

@NathanKleekamp
Copy link

@s2t2 Thanks for your help, and nice write up! Here's what ended up working for me in case it's helpful for others.

I had installed knex locally, not globally, so to run the knex cli commands, I added a knex script to my package.json file like so:

"scripts": {
    "knex": "knex"
  }

When trying to create the migrations via npm run knex migrate:make test_migration --knexfile path/to/knexfile.js, the --knexfile flag wasn't being passed to knex cli via npm.

Adding the --knexfile flag to the package.json script fixed it:

"scripts": {
    "knex": "knex --knexfile 'path/to/knexfile.js'"
  },

@kibertoad
Copy link
Collaborator

Message was really unclear and it doesn't look like that split was doing anything useful, hence I'm getting rid of it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants