How to easily verify correct npm dependencies installed?

后端 未结 6 964
北海茫月
北海茫月 2020-12-07 01:52

How can I know when to prompt user to run npm install if there are any unmet package.json dependencies?

I would like to do this, because if any re

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-12-07 02:21

    Found this today. Not sure if your still need this.

    https://www.npmjs.com/package/check-dependencies

    npm install check-dependencies --save-dev
    

    Install this package and save to your package.json.

    require('check-dependencies')(config, callback);
    

    config is the following object, which is then passed to the callback.

    {
        status: number,      // 0 if successful, 1 otherwise
        depsWereOk: boolean, // true if dependencies were already satisfied
        log: array,          // array of logged messages
        error: array,        // array of logged errors
    }
    

提交回复
热议问题