che icon indicating copy to clipboard operation
che copied to clipboard

[UDI] Configure UDI images to allow `npm install -g` within workspaces

Open amisevsk opened this issue 3 years ago • 4 comments

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

amisevsk avatar Sep 30 '22 18:09 amisevsk

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.

che-bot avatar Jul 22 '23 01:07 che-bot

/remove-lifecycle stale

amisevsk avatar Jul 24 '23 15:07 amisevsk

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.

che-bot avatar Jan 20 '24 01:01 che-bot

/remove-lifecycle stale

AObuchow avatar Jan 20 '24 12:01 AObuchow