Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to include node_modules also while 'npm pack'

Tags:

npm

I need to include some modules along with the application while 'npm pack'.. Do we have any option to include npm modules along with application?

like image 676
Jayesh Avatar asked Jan 30 '17 17:01

Jayesh


1 Answers

Inside package.json, we can specify list of dependencies that need to be bundled while packaging.

....
  "bundledDependencies": [
    "dependency_1",
    "dependency_2"
]
....

More details on bundledDependency can be found here It may be more manual work to maintain this list. To help this, there is a library called bundle-deps

Usage

$ bundle-deps [path/to/project]
bundled 48 dependencies.
$ npm pack
// you will see the packaged file contains all your dependencies specified.

Alternatively, "bundledDependencies" can be defined as a boolean value. A value of true will bundle all dependencies, a value of false will bundle none.

bundledDependencies documentation

like image 197
Sairam Krish Avatar answered Nov 17 '22 14:11

Sairam Krish