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?
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 .
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'.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With