-
-
Notifications
You must be signed in to change notification settings - Fork 34.2k
Closed
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.
Description
What is the problem this feature will solve?
Currently the node resolution will traverse all the way up to the root of the file-system.
It would be great to have a way to stop the resolution at a specific directory.
There are different use-cases that could benefit from this
- monorepos with
package.jsonfiles at different levels- e.g. a nested project that has it's own
package.jsonfile may wish to only use dependencies in this project to make sure, that no other dependencies are used by accident - Related Stackoverflow Question
- e.g. a nested project that has it's own
- some tools output artifacts to a
distdirectory which may include a separatenode_modulesfolder (with only the packages that are required for production)- the whole dist directory is meant to be self-contained: i.e. we can copy the dir to another PC and just start the app
- during development developers will just start the app from their dist directory to see if it works
- again, this can work by accident: when a required package is missing from
.dist/node_modules, node might find it in./node_modules
- again, this can work by accident: when a required package is missing from
What is the feature you are proposing to solve the problem?
Not sure what the best way is. Here are some thoughts:
- Maybe add a new property to
package.json: e.g.resolutionRoot: true
Then nested packages could directly use this. And for the dist-use case, the build-process can create apackage.jsonfile in thedistdirectory - or maybe this should be another file - different to
package.json - or use an environment variable instead
- or a cmd-line argument for node, ..
What alternatives have you considered?
Currently we copy the whole folder and subfolders to the root of the file-system and start the app from there: then the node-resolution will for sure not find additional node_module folders.
Cons:
- copying takes time and space
- the directories are not deleted automatically
- when we have many projects, the file-system is cluttered up
Metadata
Metadata
Assignees
Labels
feature requestIssues that request new features to be added to Node.js.Issues that request new features to be added to Node.js.