stackblitz / webcontainer-core

Dev environments. In your web app.
https://webcontainers.io
MIT License
3.93k stars 172 forks source link

Support global package installations #1116

Open ShukantPal opened 1 year ago

ShukantPal commented 1 year ago

Is your feature request related to a problem? Please describe.

I am trying to setup github.com/ShukantPal/pixi-essentials in StackBlitz. However, to do so I need a global installation of @microsoft/rush which is not possible in StackBlitz.

image

Describe the solution you'd like

Support global packages in the WebContainer

fvsch commented 1 year ago

Transfered this feature request to stackblitz/webcontainer-core for the WebContainer's team consideration.

fvsch commented 1 year ago

Note that while we don't support global package installs at this point, and we may choose to not support them (because every instance of a WebContainers-based project has a new environment, so reloading the page would lose your globally installed packages…), there are a few workarounds:

  1. Adding this package to your devDependencies. That might be the best practice to follow if you want your project to be usable by others (or in CI) without extra manual setup steps.
  2. Or calling it with npx or pnpm dlx.
ShukantPal commented 1 year ago

Thanks @fvsch.

Unfortunately, adding Rush to devDependencies won’t work because my install script requires Rush to be pre-installed. Rush is a monorepo manager that does package linking/setup.

As I see it, StackBlitz can’t be used for developing on monorepos?

fvsch commented 1 year ago

As I see it, StackBlitz can’t be used for developing on monorepos?

I don't think that's a fair representation. The majority of monorepo tooling doesn't require global installs, as far as I know. But yes, when it comes to Rush, unless their specific workarounds for CI and other environments that don’t support global installs work on StackBlitz, then this tool might not be supported on StackBlitz currently.

ShukantPal commented 1 year ago
image

Yep, I run into this trying that workaround.

ShukantPal commented 1 year ago

pnpm dlx @microsoft/rush runs into the same issue.

image

Perhaps there’s something in the StackBlitz environment that makes Rush incompatible, apart from global installations not being available.

Thanks for your input on this.

Nemikolh commented 1 year ago

Hi @ShukantPal ! Thanks for opening this ticket!

Currently we don't allow installing packages globally because of permissions. It also doesn't make a lot of sense because every time you refresh the project, the global packages are gone.

However you are not the first to have run into this issue and we are considering our options to make sure we have a good story for global packages.

I also noticed, from one of your screenshot, that you faced another issue where it says Unable to calculate start time for current process.

I believe this is caused by some os APIs missing. Those should be coming very soon™ :smiley: