pebblexe
pebblexe

Reputation: 165

trying to get package.json knex commands to work

I am currently using a knex project created by someone on github.

I am having trouble with the package.json as it looks like it should make the knex commands easy to run:

{
  "name": "database",
  "version": "1.0.0",
  "description": "## Steps",
  "main": "index.js",
  "scripts": {
    "init": "knex init",
    "migrate:make": "knex migrate:make",
    "migrate:latest": "knex migrate:latest",
    "migrate:rollback": "knex migrate:rollback",
    "seed:make": "knex seed:make",
    "seed:run": "knex seed:run",
    "test": "tape tests.js"
  },
  "author": "",
  "license": "ISC",
  "devDependencies": {
    "tape": "^4.5.1"
  },
  "dependencies": {
    "knex": "^0.11.5",
    "sqlite3": "^3.1.4"
  }
}

None of the commands work for me, except for npm test for some reason. I tried installing knex globally (I'm not sure if that's required) and I am still having the same issues.

Here is an example output:

npm seed:run

Usage: npm <command>

where <command> is one of:
    access, adduser, bin, bugs, c, cache, completion, config,
    ddp, dedupe, deprecate, dist-tag, docs, edit, explore, get,
    help, help-search, i, init, install, install-test, it, link,
    list, ln, login, logout, ls, outdated, owner, pack, ping,
    prefix, prune, publish, rb, rebuild, repo, restart, root,
    run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, tag, team, test, tst, un, uninstall,
    unpublish, unstar, up, update, v, version, view, whoami

npm <cmd> -h     quick help on <cmd>
npm -l           display full usage info
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    /root/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

Upvotes: 1

Views: 2111

Answers (1)

Romain
Romain

Reputation: 817

When you want to run a script defined in the scripts block, you have to run it using the following syntax: npm run <script_name>.

npm test works because it's a special case, like for example npm install.

Upvotes: 3

Related Questions