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.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
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.Beta Was this translation helpful? Give feedback.
All reactions