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
{{ message }}
Repository navigation
Cannot find module when sub-package depends on the root package #762
Due to our file structure not exactly matching what Node expects (i.e. we don't have node_modules and we have an extra version directory), sub packages within an installed binary can't require anything from the main package. This causes problems in @vue/cli, as running the command vue ui results in @vue/cli-ui (a dependency) trying to require('@vue/cli/lib/util/rcPath') (a module in the root package), which fails because Node can't find the root package.
We should come up with a directory structure that adheres to Node's resolution algorithm or otherwise come up with a way of installing tools so that the root package can be accessed from sub-packages.
One thought (which may also simplify a lot of the work around package installs and the interop between them):
Create a structure like the following: tools/packages/{node_version}/
Then instead of the bespoke logic we use, call npm i -g --prefix=${VOLTA_HOME}/tools/packages/{node_version} to effectively leverage the existing global install behavior from npm.
Some concerns with this: It silos packages off by the Node version, which is one of the things we explicitly wanted to avoid with Volta. While we can still use the shim behavior to run the tool in any context, it means some of the interoperability would be limited by specific Node version, which seems difficult to explain in docs and confusing for users.
Activity
charlespierce commentedon Jun 11, 2020
One thought (which may also simplify a lot of the work around package installs and the interop between them):
Create a structure like the following:
tools/packages/{node_version}/Then instead of the bespoke logic we use, call
npm i -g --prefix=${VOLTA_HOME}/tools/packages/{node_version}to effectively leverage the existing global install behavior fromnpm.Some concerns with this: It silos packages off by the Node version, which is one of the things we explicitly wanted to avoid with Volta. While we can still use the shim behavior to run the tool in any context, it means some of the interoperability would be limited by specific Node version, which seems difficult to explain in docs and confusing for users.
charlespierce commentedon Oct 22, 2020
With Volta 0.9.0, now that we are using the package manager directory layout, this should no longer be an issue as there is a
node_modulesdirectory.