How to use executables from a package installed locally in node_modules?

前端 未结 22 2319
时光说笑
时光说笑 2020-11-22 12:40

How do I use a local version of a module in node.js. For example, in my app, I installed coffee-script:

npm install coffee-script
22条回答
  •  星月不相逢
    2020-11-22 12:59

    I've always used the same approach as @guneysus to solve this problem, which is creating a script in the package.json file and use it running npm run script-name.

    However, in the recent months I've been using npx and I love it.

    For example, I downloaded an Angular project and I didn't want to install the Angular CLI globally. So, with npx installed, instead of using the global angular cli command (if I had installed it) like this:

    ng serve
    

    I can do this from the console:

    npx ng serve
    

    Here's an article I wrote about NPX and that goes deeper into it.

提交回复
热议问题