Search code examples
node.jsnode-modulespackage.jsonnpm-scriptskss

How to run kss package? Script not recognized by node


I want to create a CSS documentation and installed KSS Doc: https://github.com/kneath/kss

But the script (kss --css ../styles/style.css --source styles) doesn't work as written in the doc. I don't use Webpack or any fremework, so only have a package.json file.

Here is how to use KSS: https://github.com/kss-node/kss-node

For example, $ kss --demo doesn't work. Should i add script in my package.json file, and if yes, what? Or do I need Webpack? I'm using node 10.15.3 and KSS is old too.

The error I get:

$ npm run kss --confignode_modules/kss/demo/kss-config.json
npm ERR! missing script: kss

I would like to be able to run the script, give the source and destination as explained in the doc. Thanks.


Solution

  • You need to add a script to your package.json in order to run it:

    {
        ...
        "scripts": {
             ...
            "kss": "node ./node_modules/kss/index.js" // `node` is required on Windows
        }
        ...
    }
    

    and then run it like this:

    npm run kss -- --config node_modules/kss/demo/kss-config.json
    

    Not the additional -- after the script name. It tells npm that the following arguments need to be passed to the kss command itself and not to the npm run command.