You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I often accidentally run npm install to add a new frontend dependency while being in the wrong directory, which results in automatic creation of node_modules, package.json, package-lock.json in the wrong place. I don't how many people besides me run into this problem, maybe everyone else is much more disciplined about checking their CWD.
If indeed it's a common problem, I would like to propose a config flag that could be added to ~/.npmrc to prevent situations like this, i.e. only allow installing non-global packages while inside a directory with an existing package.json file.
install-only-with-package-json = true
The text was updated successfully, but these errors were encountered:
Hi @sryze
Thank you for the suggestion, According to GitHub guidelines, new feature and suggestions are discussed in the npm feedback forum. Recommended to open a discussion in the npm feedback forum. You can visit here https://github.com/npm/feedback/discussions
For example, I have a project with a nested structure (monorepo) where frontend code is located a few levels deep in the directory hierarchy:
I often accidentally run
npm install
to add a new frontend dependency while being in the wrong directory, which results in automatic creation ofnode_modules
,package.json
,package-lock.json
in the wrong place. I don't how many people besides me run into this problem, maybe everyone else is much more disciplined about checking their CWD.If indeed it's a common problem, I would like to propose a config flag that could be added to
~/.npmrc
to prevent situations like this, i.e. only allow installing non-global packages while inside a directory with an existingpackage.json
file.The text was updated successfully, but these errors were encountered: