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

Failed to run on arm platforms #5194

Closed
joshuaavalon opened this issue Oct 12, 2023 · 22 comments · Fixed by #5471
Closed

Failed to run on arm platforms #5194

joshuaavalon opened this issue Oct 12, 2023 · 22 comments · Fixed by #5471

Comments

@joshuaavalon
Copy link

Rollup Version

4.0.2

Operating System (or Browser)

Alpine 3.18

Node Version (if applicable)

18.18.1

Link To Reproduction

https://github.com/joshuaavalon/rollup-arm-bug

Expected Behaviour

Build successfully like other platforms.

Actual Behaviour

When you use node:18-alpine Docker and target platform like linux/arm/v6 and linux/arm/v7, it show the following error.

https://github.com/joshuaavalon/rollup-arm-bug/actions/runs/6490693336/job/17626861855

#24 31.37 > rollup-arm-bug@1.0.0 build
#24 31.37 > rollup -c
#24 31.37
#24 33.63 node:internal/modules/cjs/loader:1340
#24 33.63 return process.dlopen(module, path.toNamespacedPath(filename));
#24 33.63 ^
#24 33.63
#24 33.63 Error: Error loading shared library ld-linux-armhf.so.3: No such file or directory (needed by /app/node_modules/@rollup/rollup-linux-arm-gnueabihf/rollup.linux-arm-gnueabihf.node)
#24 33.63 at Module._extensions..node (node:internal/modules/cjs/loader:1340:18)
#24 33.63 at Module.load (node:internal/modules/cjs/loader:1119:32)
#24 33.63 at Module._load (node:internal/modules/cjs/loader:960:12)
#24 33.63 at Module.require (node:internal/modules/cjs/loader:1143:19)
#24 33.63 at require (node:internal/modules/cjs/helpers:119:18)
#24 33.63 at Object. (/app/node_modules/rollup/dist/native.js:49:36)
#24 33.63 at Module._compile (node:internal/modules/cjs/loader:1256:14)
#24 33.63 at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
#24 33.63 at Module.load (node:internal/modules/cjs/loader:1119:32)
#24 33.63 at Module._load (node:internal/modules/cjs/loader:960:12) {
#24 33.63 code: 'ERR_DLOPEN_FAILED'
#24 33.63 }

@sschultze
Copy link

On Windows ARM64 (with ARM64 Node.js), process.dlopen fails as well. A good workaround is using @rollup/wasm-node instead.

@lukastaegert
Copy link
Member

lukastaegert commented Nov 16, 2023

It looks like the problem is that we do not have a MUSL build for regular arm architectures (i.e. not arm64). I will have a look in the next days if we can set one up. Not sure about the windows issue, though. I would be rather surprised if that failed because it cannot find ld-linux-armhf.so.

@newives
Copy link

newives commented Nov 17, 2023

The same problem occurs on Windows. Vite relies on rollup, causing the Vite project to fail to run.

图片 图片

@morpheus-87
Copy link

morpheus-87 commented Nov 22, 2023

I've got another error on my Raspberry Pi:

> tsc && vite build

node:internal/modules/cjs/loader:1338
  return process.dlopen(module, path.toNamespacedPath(filename));
                 ^

Error: node_modules/@rollup/rollup-linux-arm-gnueabihf/rollup.linux-arm-gnueabihf.node: cannot open shared object file: No such file or directory
    at Module._extensions..node (node:internal/modules/cjs/loader:1338:18)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12)
    at Module.require (node:internal/modules/cjs/loader:1141:19)
    at require (node:internal/modules/cjs/helpers:110:18)
    at Object.<anonymous> (/drone/src/node_modules/rollup/dist/native.js:60:48)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10)
    at Module.load (node:internal/modules/cjs/loader:1117:32)
    at Module._load (node:internal/modules/cjs/loader:958:12) {
  code: 'ERR_DLOPEN_FAILED'
}

Node.js v18.16.0

Is this caused by the same issue?

@lukastaegert
Copy link
Member

Probably. Unfortunately, I was not able to cross-compile an ARM Linux build for MUSL systems, which yours likely is. I would have hoped you get a better error with latest Rollup, though, which should point you to use the WASM build.

@morpheus-87
Copy link

Thank you very much for the clarification! How could I achieve a WASM build with Vite?

@patak-dev
Copy link
Contributor

@morpheus-87, 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)

@morpheus-87
Copy link

morpheus-87 commented Nov 30, 2023

Thanks for your help, @patak-dev , it works like a charm 🥳 because I'm using npm, I had to add the following snippet to my package.json:

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

@BeycanDeveloper
Copy link

@morpheus-87 this not working for me also i cannot install this package on my docker container

@patak-dev can you help me?

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

@silvenon
Copy link

silvenon commented Jan 4, 2024

It doesn't work for me either, with npm 😕 I tried the following just in case, I tried overriding it all the way as well just in case:

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

Ensured that it was indeed overridden:

❯ npm why rollup
rollup@4.9.1 dev overridden
node_modules/rollup
  overridden rollup@"npm:@rollup/wasm-node" (was "^4.2.0") from vite@5.0.10
  node_modules/vite
  ...

But getting the same error on vite build:

Error: Cannot find module @rollup/rollup-linux-arm64-musl.

Using node:18-alpine Docker image.

EDIT: I'm starting to think that npm's overrides doesn't have this feature yet.

@BeycanDeveloper
Copy link

@silvenon you can try yarn, this working.

@silvenon
Copy link

silvenon commented Jan 4, 2024

What did work with npm was specifying a version higher than what my rollup previously was:

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

My rollup was previously 4.9.1. I have no idea why this works, it seems like a bug with npm and overrides, like it only "notices" them if there's something new, otherwise it doesn't update package-lock.json.

Now building my app works! 🥳

@filipbekic01
Copy link

Can't manage to run it.

@leo-petrucci
Copy link

I'm switching from Yarn to pnpm and getting this on a project that previously worked just fine.

Adding:

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

Seems to fix that particular error, but then it just errors out with:

Error: Your application tried to access rollup, but it isn't declared in your dependencies; this makes the require call ambiguous and unsound.

Required package: rollup
Required by: node_modules/.pnpm/vite@5.1.3_@types+node@20.11.19/node_modules/vite/dist/node/chunks/

🤷‍♂️

I have used Vite with pnpm before without issues so I'm very confused as to why it's suddenly not working. I'm assuming there's some other issue afoot but I really can't think of anything.

@Reeska
Copy link

Reeska commented Feb 26, 2024

Today I upgraded to latest vite version and I got this issue on Gitlab CI, with this stack trace:

> vite build
/builds/front-js-components/ocs/ocs-apps/apps/ocs-stb/node_modules/rollup/dist/native.js:87
		throw new Error(
		      ^
Error: Cannot find module @rollup/rollup-linux-x64-gnu. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4[82](https://gt.ocs.fr/front-js-components/ocs/ocs-apps/-/jobs/161001#L82)8). Please try `npm i` again after removing both package-lock.json and node_modules directory.
    at requireWithFriendlyError (/builds/front-js-components/ocs/ocs-apps/apps/ocs-stb/node_modules/rollup/dist/native.js:87:9)
    at Object.<anonymous> (/builds/front-js-components/ocs/ocs-apps/apps/ocs-stb/node_modules/rollup/dist/native.js:96:76)
    ... 3 lines matching cause stack trace ...
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at cjsLoader (node:internal/modules/esm/translators:356:17)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:305:7)
    at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24) {
  [cause]: Error: Cannot find module '@rollup/rollup-linux-x64-gnu'
  Require stack:

I try to override rollup version used by vite with the following trick in package.json, but it didn't change anything:

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

I have found a workaround : removing the package-lock.json allow Gitlab CI to install dependencies correctly. But it's not great solution...

@citrusjunoss
Copy link

citrusjunoss commented Mar 15, 2024

How can I fix it, I don't want to delete the lock file, which would cause the project's dependencies to be upgraded, which would create new problems

> node ./scripts/build.mjs --appid=$npm_config_appid --pipeid=$npm_config_pipeid --domain=$npm_config_domain /builds/open/frontend/open-api-doc/node_modules/rollup/dist/native.js:87 throw new Error( ^ Error: Cannot find module @rollup/rollup-linux-x64-musl. npm has a bug related to optional dependencies (https://github.com/npm/cli/issues/4828). Please try npm i` again after removing both package-lock.json and node_modules directory.
at requireWithFriendlyError (/builds/open/frontend/open-api-doc/node_modules/rollup/dist/native.js:87:9)
at Object. (/builds/open/frontend/open-api-doc/node_modules/rollup/dist/native.js:96:76)
... 3 lines matching cause stack trace ...
at Module._load (node:internal/modules/cjs/loader:1023:12)
at cjsLoader (node:internal/modules/esm/translators:356:17)
at ModuleWrap. (node:internal/modules/esm/translators:305:7)
at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
at async ModuleLoader.import (node:internal/modules/esm/loader:329:24) {
[cause]: Error: Cannot find module '@rollup/rollup-linux-x64-musl'
Require stack:

  • /builds/open/frontend/open-api-doc/node_modules/rollup/dist/native.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
    at Module._load (node:internal/modules/cjs/loader:985:27)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at requireWithFriendlyError (/builds/open/frontend/open-api-doc/node_modules/rollup/dist/native.js:69:10)
    at Object. (/builds/open/frontend/open-api-doc/node_modules/rollup/dist/native.js:96:76)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12) {
    code: 'MODULE_NOT_FOUND',
    requireStack: [
    '/builds/open/frontend/open-api-doc/node_modules/rollup/dist/native.js'
    ]
    }
    }
    Node.js v20.11.0`

@sapphi-red
Copy link
Contributor

I was able to build for armv7 musl by adding 'armv7-unknown-linux-musleabihf': 'arm-linux-musleabihf' to https://github.com/napi-rs/napi-rs/blob/8eea78054a557be7532288f450b7efa0507223be/cli/src/build.ts#L29-L41, but it stuck on nodejs/docker-node#1798 when running tests for napi-rs. Given that armv7 musl isn't included in tier 1 or tier2 support of Node.js, it might break any time and I guess adding a build for this would cause a big maintenance burden.

@lukastaegert
Copy link
Member

it might break any time

Only if we change the rust version too often. As it stands, we did not do that more than once, and I do not plan on doing it too often. So I would not see that as an argument, but apparently there is some demand for that platform.

@juliusiqbal
Copy link

juliusiqbal commented Apr 1, 2024

I had to use below code in package.json file and remove node_modules folder and run npm install.

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

I had to run below commands for dockerized app where npm i should run inside container.

docker compose run reusebin-ui npm i && \
  docker compose down && \
  rm -rf node_modules && \
  docker compose up --build

@sapphi-red
Copy link
Contributor

sapphi-red commented Apr 1, 2024

it might break any time

Only if we change the rust version too often. As it stands, we did not do that more than once, and I do not plan on doing it too often. So I would not see that as an argument, but apparently there is some demand for that platform.

It's not only rust, but also the node version needs to be fixed. After upgrading node version a test might fail.


Made a PR upstream: napi-rs/napi-rs#2019, napi-rs/napi-rs#2020

@lukastaegert
Copy link
Member

Now that I actually managed to add smoke tests for (emulated) ARM v7 to the pipeline, I think I see what you mean. Of course it could also be a bug in the emulator, but the MUSL version does not run, not because of Rollup but because running npm itself just hangs and does not recover. The GNU version runs fine, though: https://github.com/rollup/rollup/actions/runs/8774450926/job/24075678218

@connorfinnigan512
Copy link

I encountered this again and was able to resolve by running npm install from inside the container:
docker compose run {your_service_name} npm install

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.