Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

5.0.2 Cannot find module '@rollup/rollup-linux-arm64-gnu' on multi platform build #15167

Closed
7 tasks done
zthun opened this issue Nov 27, 2023 · 6 comments
Closed
7 tasks done

Comments

@zthun
Copy link

zthun commented Nov 27, 2023

Describe the bug

I have a multi platform build which runs on mac/windows locally while developing and on linux in a docker container. When I try to run the app in a docker container, even through my yarn file contains both current and linux as the supported architectures, I receive an error

works-zthunworks-services-web-1  | 
works-zthunworks-services-web-1  | Error: Cannot find module '@rollup/rollup-linux-arm64-gnu'
works-zthunworks-services-web-1  | Require stack:
works-zthunworks-services-web-1  | - /usr/dev/node_modules/vite/node_modules/rollup/dist/native.js
works-zthunworks-services-web-1  |     at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
works-zthunworks-services-web-1  |     at Module._load (node:internal/modules/cjs/loader:901:27)
works-zthunworks-services-web-1  |     at Module.require (node:internal/modules/cjs/loader:1115:19)
works-zthunworks-services-web-1  |     at require (node:internal/modules/helpers:130:18)
works-zthunworks-services-web-1  |     at Object.<anonymous> (/usr/dev/node_modules/vite/node_modules/rollup/dist/native.js:49:48)
works-zthunworks-services-web-1  |     at Module._compile (node:internal/modules/cjs/loader:1241:14)
works-zthunworks-services-web-1  |     at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
works-zthunworks-services-web-1  |     at Module.load (node:internal/modules/cjs/loader:1091:32)
works-zthunworks-services-web-1  |     at Module._load (node:internal/modules/cjs/loader:938:12)
works-zthunworks-services-web-1  |     at cjsLoader (node:internal/modules/esm/translators:284:17) {
works-zthunworks-services-web-1  |   code: 'MODULE_NOT_FOUND',
works-zthunworks-services-web-1  |   requireStack: [ '/usr/dev/node_modules/vite/node_modules/rollup/dist/native.js' ]

This worked just fine with 4.x and if an architecture was missing from 4.x it would actually warn you to add the supported architectures to .yarnrc file

My vite.config.js is minimal:

import { defineConfig } from 'vite';
import tsConfigPaths from 'vite-tsconfig-paths';

export default defineConfig({
  plugins: [tsConfigPaths()],
  server: {
    host: '0.0.0.0',
    strictPort: true
  },
  resolve: {
    alias: {
      lodash: 'lodash-es'
    }
  }
});

Reproduction

https://github.com/zthun/works

Steps to reproduce

You will need docker, git, and yarn installed at minimum.

# Mac
brew install git
brew install yarn
brew install docker
# Windows
choco install git
choco install yarn 
choco install docker-desktop
git clone https://github.com/zthun/works
yarn install
docker compose up

This results in the error for the works-web project:

works-zthunworks-services-web-1  | Error: Cannot find module '@rollup/rollup-linux-arm64-gnu'
works-zthunworks-services-web-1  | Require stack:
works-zthunworks-services-web-1  | - /usr/dev/node_modules/vite/node_modules/rollup/dist/native.js
works-zthunworks-services-web-1  |     at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
works-zthunworks-services-web-1  |     at Module._load (node:internal/modules/cjs/loader:901:27)
works-zthunworks-services-web-1  |     at Module.require (node:internal/modules/cjs/loader:1115:19)
works-zthunworks-services-web-1  |     at require (node:internal/modules/helpers:130:18)
works-zthunworks-services-web-1  |     at Object.<anonymous> (/usr/dev/node_modules/vite/node_modules/rollup/dist/native.js:49:48)
works-zthunworks-services-web-1  |     at Module._compile (node:internal/modules/cjs/loader:1241:14)
works-zthunworks-services-web-1  |     at Module._extensions..js (node:internal/modules/cjs/loader:1295:10)
works-zthunworks-services-web-1  |     at Module.load (node:internal/modules/cjs/loader:1091:32)
works-zthunworks-services-web-1  |     at Module._load (node:internal/modules/cjs/loader:938:12)
works-zthunworks-services-web-1  |     at cjsLoader (node:internal/modules/esm/translators:284:17) {
works-zthunworks-services-web-1  |   code: 'MODULE_NOT_FOUND',
works-zthunworks-services-web-1  |   requireStack: [ '/usr/dev/node_modules/vite/node_modules/rollup/dist/native.js' ]

System Info

System:
    OS: macOS 14.1.1
    CPU: (10) arm64 Apple M2 Pro
    Memory: 418.97 MB / 32.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.9.0 - ~/.nvm/versions/node/v20.9.0/bin/node
    Yarn: 3.3.1 - /opt/homebrew/bin/yarn
    npm: 10.1.0 - ~/.nvm/versions/node/v20.9.0/bin/npm
  Browsers:
    Chrome: 119.0.6045.159
    Firefox: 120.0
    Safari: 17.1
  npmPackages:
    vite: ^5.0.2 => 5.0.2

Used Package Manager

yarn

Logs

No response

Validations

@patak-dev
Copy link
Member

Would you check if this fixes your issue too?
#15120 (comment)

@zthun
Copy link
Author

zthun commented Nov 27, 2023

@patak-dev

Tried it. I removed node_modules and deleted yarn.lock. Did not work. I did the same thing, then upgraded yarn from 3.x to 4.x. Same issue. I did some digging, and I'm pretty sure the issue is because vite 5.x upgraded to rollup 4.x and the related breaking change in rollup was this:

The NodeJS build now relies on an optional native binary; for unsupported platforms, users can use the @rollup/wasm-node package that has the same interface as Rollup but relies on WASM artifacts (rollup/rollup#5073)

I'm pretty sure I'm running into this issue here: rollup/rollup#5194. I'm not getting any errors from yarn, but even though I've specified multiple architectures in my yarnrc file, I'm only able to retrieve the darwin and windows binaries from rollup.

Is there any way to use vite with the @rollup/wasm-node package? This is going beyond my knowledge level here.

@patak-dev
Copy link
Member

See my last comment on the rollup issue you linked rollup/rollup#5194 (comment)

To force @rollup/wasm-node, if you are using pnpm, you can add an override in your package.json:

  "pnpm": {
    "overrides": {
      "rollup": "npm:@rollup/wasm-node"
    }
  }

Other package manager have similar features (npm, yarn)

Let's close this issue for now, as it can be tracked in rollup

@patak-dev patak-dev closed this as not planned Won't fix, can't repro, duplicate, stale Nov 28, 2023
@AmirTugi
Copy link

AmirTugi commented Nov 29, 2023

See my last comment on the rollup issue you linked rollup/rollup#5194 (comment)

To force @rollup/wasm-node, if you are using pnpm, you can add an override in your package.json:

  "pnpm": {
    "overrides": {
      "rollup": "npm:@rollup/wasm-node"
    }
  }

Other package manager have similar features (npm, yarn)

Let's close this issue for now, as it can be tracked in rollup

I can verify that this works with yarn's resolutions

"resolutions": {
  "rollup": "npm:@rollup/wasm-node"
}

@zthun
Copy link
Author

zthun commented Nov 29, 2023

Note that if you're on yarn 2+, then you'll also need the range as well:

"resoltuions": {
    "rollup": "npm:@rollup/wasm-node@*"
}

@morpheus-87
Copy link

I can also verify that it works with npms overrides:

"overrides": {
  "vite": {
    "rollup": "npm:@rollup/wasm-node"
  }
}

@github-actions github-actions bot locked and limited conversation to collaborators Dec 15, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants