Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure "Web apps" service: auto-install npm modules from package.json

I deployed a node.js app in an azure "web apps" container. I added the "node_modules" folder to .gitignore and let azure install modules from package.json.

However, most modules do not get automatically installed and i have to open the instance's command line and install them manually using "npm install".

I am using node v0.12.0 and here is my package.json:

{
 "main": "server.js",
 "scripts": {
   "start": "node server.js"
 },
 "devDependencies": {
  "body-parser": "^1.12.4",
  "cors": "^2.6.1",
  "express": "*",
  "gulp": "^3.8.11",
  "gulp-jshint": "^1.11.0",
  "gulp-nodemon": "^2.0.3",
  "moment": "^2.10.3",
  "mongoose": "^4.0.3"
},
"engines": {
  "node": "0.12.0"
}
}

How can I enable automatic installation of modules through azure web apps and not be obliged to push the "node_modules" folder with each commit?

like image 991
ccot Avatar asked May 28 '15 14:05

ccot


People also ask

Does npm install automatically add to json?

By default, npm install will install all modules listed as dependencies in package. json . With the --production flag (or when the NODE_ENV environment variable is set to production ), npm will not install modules listed in devDependencies .

How npm install all dependencies from package json?

NPM installs devDependencies within the package. json file. The 'npm install' command should add all the dependencies and devDependencies automatically during installation. If you need to add specific devDependencies to your project, you can use this command- 'npm install --save-dev'.

Which package manager gets automatically installed when you install node js?

NPM is included with Node. js installation. After you install Node. js, verify NPM installation by writing the following command in terminal or command prompt.


1 Answers

Azure does not install the devDependencies. If you need them on production, it is not devDependencies but dependencies

In your package.json, devDependencies should be renamed to dependencies

This kind of thing appens when you npm install --save-dev.

Production dependency (needed to run): npm install --save
Otherwise (build tools, jshint, etc.): npm install --save-dev

like image 139
Jonathan Muller Avatar answered Oct 27 '22 17:10

Jonathan Muller