[UDI] Configure UDI images to allow `npm install -g` within workspaces
Is your enhancement related to a problem? Please describe
Some node projects rely on packages installed from npm/yarn, e.g. gulp. Currently, the UDI images used by default in workspaces do not necessarily have all required packages installed, and provide no easy means of installing them -- npm install -g in workspaces fails with a permissions error attempting to write to /usr/local/lib/node_modules.
Describe the solution you'd like
We probably don't want to pre-install every possible dependency in the container itself, but we can enable installing dependencies within workspaces by configuring npm and yarn to use writeable directories:
- ~/.npmrc
prefix=/projects/.node_modules_global - ~/.yarnrc
prefix "/projects/.yarn_global"
Then adding PATH=$PATH:/projects/.node_modules_global/bin/:/projects/.yarn_global/bin/ should allow using npm install -g <package> or yarn global add <package> in workspaces.
Describe alternatives you've considered
Alternatively, another writeable path, outside the shared /projects directory could be used. This would mean that installed modules do not use workspace storage, but also means that installed packages are lost when the workspace restarts.
Additional context
Initially raised in https://github.com/eclipse/che/issues/21741
Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.
Mark the issue as fresh with /remove-lifecycle stale in a new comment.
If this issue is safe to close now please do so.
Moderators: Add lifecycle/frozen label to avoid stale mode.
/remove-lifecycle stale
Issues go stale after 180 days of inactivity. lifecycle/stale issues rot after an additional 7 days of inactivity and eventually close.
Mark the issue as fresh with /remove-lifecycle stale in a new comment.
If this issue is safe to close now please do so.
Moderators: Add lifecycle/frozen label to avoid stale mode.
/remove-lifecycle stale