1

by default, npm install and npm start look for package.json.

Is there a way to specify to use a different package.json file?

========

Something like package.json, package_dev.json, package_staging.json, package_dev_features.json when run npm install, i can specify which package*.json to be used instead of the default package.json

========

The reason is, it may be easier to handle using different packages for development / testing.

========= Final solution:

At the end, i just have one package.json for each environment (or branch). and set environment for dependencies . e.g. 'myLodash':"github.com/.../myLodash.git#testing"

Then when I merge from one environment to another, (e.g. from testing to staging), I merge the package.json. and then run a script to check & update the dependencies. Then push the updated package.json

it is a bit more works but it works. :)

=========

murvinlai
  • 48,919
  • 52
  • 129
  • 177
  • such as, a package.json located in a sub folder? – Kevin B Nov 24 '15 at 23:28
  • Something like package.json, package_dev.json, package_staging.json, package_dev_features.json when run npm install, i can specify which package*.json to be used instead of the default package.json – murvinlai Dec 13 '15 at 06:44
  • There isn't a way. See [this question](http://stackoverflow.com/questions/33826872/npm-install-specify-package-json) and the [documentation](https://docs.npmjs.com/cli/install) – Jack Guy Dec 13 '15 at 06:51

1 Answers1

0

You may use the dependencies and devDependencies in your package json file.

For installing a module only in development, use this:

npm install --save-dev request

For installing a module in production, use this:

npm install --save request
Luís Brito
  • 1,652
  • 1
  • 17
  • 34
  • what if i want to run the start script of an installed package? – Michael Jan 17 '17 at 21:46
  • @Michael hm, that's weird but you can find the directory of the module in the `node_modules/` and using `cd node_module/some_pkg` run the `npm start` inside of it. I don't think there's a way to do this directly. – Luís Brito Jan 20 '17 at 17:53