asked on
managing packages with npm in react js project?
I have a feature branch in reactjs project, where i installed a npm package in my local machine, using following command
npm install pm2
then i ran the pm2 command on the root of the project folder. I got command not found, so then i installed with -g flag. npm install pm2 -g
it added the package successfully. and my package.json file was modified and the package name was added as well, see below.
{"name": "my-react-proj",
"version" : "0.1.0",
"private" : true,
"dependencies" : { ....
"pm2": "^4.5.0",
....
}
....
}
I needed to work on something else, so i created another branch , say branch2. i switched to another branch. thinking, i just work on this branch , i tried to install the same package , in my new branch 2. but i doesn't change the package.json file at all. i want all the new changes in this branch now. but it looks like , somehow in my local machine, npm knows the package was already installed (in another branch though) . so i have tried, npm uninstall -g . and tried to install it. but doesn't work. I deleted the folders manually under node_modules, still doesn't work. I tried "npm prune" command as well. i also tried the npm uninstall pm2 command.
how can i completely remove this package such that , if i switch branch , i can still install it.
also, when i use npm install with a "-g" to install any packages. is -g flag saved in package.json , to identify that package needs to be installed globally , if anyone runs npm install on that project going forward.
ASKER