While pushing an angular2 app on bitbucket, do we need to also push node_modules and typings folder along? I have to deply the app on azure. As far as I understood from various articles that when we deploy on Azure then it runs npm install itself hence node_modules and typings folder get created. Please share on this.
You don't have to push the node_modules
folder with your project. If you have it declared in your dependencies in your package.json
then whoever clones your project and runs npm install
will download the correct things. An easy way to declare to package.json
is by using --save
on installation.
Ex. npm install bootstrap --save
Per Azure's documentation ,
Azure Cloud Services expect all modules to be installed on the development environment, and the node_modules directory to be included as part of the deployment package. It is possible to enable support for installing modules using package.json or npm-shrinkwrap.json files on Cloud Services, however this requires customization of the default scripts used by Cloud Service projects. For an example of how to accomplish this, see Azure Startup task to run npm install to avoid deploying node modules
They also expand on this issue:
When deploying the node_modules directory as part of your application, it will increase the size of the deployment compared to using a package.json or npm-shrinkwrap.json file; however, it does guarantee that the version of the modules used in production are the same as those used in development.
In terms of code management, there are conflicting positions whether the node_modules
folder should or shouldn't be submitted to version control. What I can say is that after the left-pad incident more and more people have been trending towards the "should commit" direction, myself included.
Should you want to follow this road, I suggest you take a look at both shrinkwrap , which locks the versions of the packages your dependencies themselves depend on, and shrinkpack which saves the actual packages as .tar
to avoid noisy commit changes.
No, node_modules
and typings
folders don't need to be pushed. npm install
will install your dependencies into those folders.
Best practice - do not push node_modules to git repository.
To avoid problems with dependencies - use module like shrinkwrap (which locks down the versions of a package's dependencies)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.