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 have a question regarding customizing the location of the node_modules folder in a Vite project. In my use case, I would like to instruct Vite to look for node_modules in a different (sibling) directory rather than the default ./node_modules, due to project constraints where dependencies are centralized in a shared folder.
I couldn’t find an option in the documentation for explicitly changing the node_modules lookup path. Is there a way to configure Vite to use a custom path for node_modules - such as a directory outside the project root or nested within a subfolder?
Here are some details about what I tried:
Changing the root directory: While this affects the project structure, it doesn't seem to influence the location where Vite resolves modules from node_modules.
Aliases in resolve.alias: I considered manually aliasing dependencies, but this approach doesn't scale well for larger projects with many dependencies.
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
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
I have a question regarding customizing the location of the
node_modulesfolder in a Vite project. In my use case, I would like to instruct Vite to look fornode_modulesin a different (sibling) directory rather than the default./node_modules, due to project constraints where dependencies are centralized in a shared folder.I couldn’t find an option in the documentation for explicitly changing the
node_moduleslookup path. Is there a way to configure Vite to use a custom path fornode_modules- such as a directory outside the project root or nested within a subfolder?Here are some details about what I tried:
node_modules.resolve.alias: I considered manually aliasing dependencies, but this approach doesn't scale well for larger projects with many dependencies.Here’s an example directory structure:
In this setup, I would like project-a to resolve dependencies from
/workspace/shared/node_modules.Is there an existing configuration option to change the default path where Vite looks for
node_modules?Beta Was this translation helpful? Give feedback.
All reactions