Reputation: 3817
I have a project with at its root the following simplified package.json
file:
package.json
{
"name": "parent-project",
"dependencies": {
...
}
}
In a subfolder that we'll call child-project
, another package.json
resides:
child-project / package.json
{
"name": "child-project",
"dependencies": {
...
}
}
Some code that I depend on uses the command npm --prefix ./child-project install
to install dependencies in child-project
. However, this always has the undesirable side-effect of altering child-project/package.json
like so:
{
"name": "child-project",
"dependencies": {
...
"parent-project": "file:.." // <- I don't want this!
}
}
When I execute cd ./child-project && npm install
all is fine and child-project/package.json
remains untouched, so my hunch is that it has to do with --prefix
but documentation on --prefix
is very obscure.
Is there a way to disable this behaviour and prevent NPM from altering the child-project/package.json
?
Upvotes: 2
Views: 1130
Reputation: 3687
Seems like there are some issues with the --prefix
.
However, I couldn't find any issue while I was testing with different modules which have sub-packages.
Hence, according to one of the npm contributors, it is going to be refactored or removed in a future release, which means it is not the best choice to use it at least for now. So I recommend you go through the traditional way and avoid using --prefix
.
I think we're gonna close this as a wontfix as --prefix is not the best flag to be promoting. We do eventually want to refactor or remove it but for now we should at least not be promoting it.
Upvotes: 2