Yes, I know, npm install -g
isn't supposed to update package.json
. But I need something that will have a similar effect.
My problem is as follows: I want to keep everything separate, so I would like to install node, npm, and every package in a virtual environment. I do this by running:
$ python -m venv <venv_name>
$ <venv_name>\scripts\activate
$ pip install nodeenv
$ nodeenv -p
These four steps download nodejs and npm in a virtual environment.
The issue I'm having is that whenever I want to install a nodejs package via npm I have to install it 'globally' in the virtual environment otherwise it doesn't work. To illustrate this, I will show you what happens when I install a package using normally with:
$ npm install express
or
$ npm install nodmeon
This will save nodemon or express in dependencies, however it wont recognize them as commands, for example:
$ nodemon run start
will return 'nodemon' is not recognized as an internal or external command
But this wont happen when I install packages with npm install -g
. They work just fine when I do that, but the problem is that they wont save in package.json
.
What I've been doing is installing things 2 times, one globally and one normally just so it can be saved in package.json.
My question is: Is there anyway for my global installations to be outputted in package.json? Or is there any way you would recommend me to solve this problem?