remix icon indicating copy to clipboard operation
remix copied to clipboard

Vite hangs on fresh npm install when using `installGlobals`

Open shaqq opened this issue 1 year ago • 4 comments

Reproduction

Spin up a remix app using the Cloudflare template, and make sure nothing is installed:

bunx create-remix@latest --template remix-run/remix/templates/cloudflare
cd my-remix-app
rm -rf node_modules

In vite.config.ts, add these lines:

import { installGlobals } from "@remix-run/node";

installGlobals();

Try to boot the app using bun run dev and you won't get any output. It'll look something like this:

➜  my-remix-app git:(main) ✗ bun run dev
$ remix vite:dev



^C

Running with bunx vite dev -d doesn't seem to show anything helpful either.

System Info

System:
    OS: macOS 14.3.1
    CPU: (8) arm64 Apple M2
    Memory: 432.41 MB / 24.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 19.5.0 - ~/.nodenv/versions/19.5.0/bin/node
    npm: 6.13.7 - /usr/local/bin/npm
    bun: 1.0.26 - /opt/homebrew/bin/bun
  Browsers:
    Chrome: 123.0.6312.58
    Safari: 17.3.1
  npmPackages:
    @remix-run/cloudflare: ^2.8.1 => 2.8.1
    @remix-run/cloudflare-pages: ^2.8.1 => 2.8.1
    @remix-run/dev: ^2.8.1 => 2.8.1
    @remix-run/react: ^2.8.1 => 2.8.1
    vite: ^5.1.0 => 5.2.3

Used Package Manager

bun

Expected Behavior

Vite should boot up and run on localhost

Actual Behavior

bunx remix vite:dev fails to run, and fails silently

shaqq avatar Mar 22 '24 23:03 shaqq

Curiously, if you install deps without installGlobals and add it back in later, Vite still seems to work!

shaqq avatar Mar 22 '24 23:03 shaqq

It doesn't look like you installed @remix-run/node as a dependency? Nor should you need to in a cloudflare app I don't think? I'm also unsure if this is a bun issue potentially - we don't specifically develop for bun, it claims to be fully node-compatible but I don't believe that's 100% the case yet

brophdawg11 avatar Mar 25 '24 16:03 brophdawg11

@remix-run/node is included in remix-serve

I tried this with npm and npx and ran into the same problem:

image

shaqq avatar Mar 26 '24 01:03 shaqq

I totally get I don't need to use installGlobals here since cloudflare doesn't need it. It just fails without any logs or information as to what to do.

My guess is that installGlobals is clobbering something that vite needs.

shaqq avatar Mar 26 '24 01:03 shaqq

There are a few things going on here

  • I can't replicate this issue (only difference is I'm on bun 1.1.0)
  • You should probably be using Node 18 or 20, not 19, since odd Node versions are experimental and even are stable
  • As @brophdawg11 mentioned you shouldn't be using installGlobals or @remix-run/node with cloudflare

I'm going to go ahead and close this since I can't reproduce and it's not really a use case we want to account for anyway

brookslybrand avatar May 22 '24 21:05 brookslybrand