Skip to content

Error: Cannot find module @rollup/rollup-linux-x64-gnu on Docker container #15492

Closed

Description

@0xBeycan

Describe the bug

I researched and tried on the sites below and on many different platforms, but I could not find a solution. I am using node:lts and also I cannot download this module in my docker container due to system incompatibility.

So I honestly don't know what to do right now.

#15120
rollup/rollup#5194
#15167

Reproduction

https://stackblitz.com/edit/vite-yxshfw?file=docker-compose.yml,package.json

Steps to reproduce

No response

System Info

System:
2024-01-03 10:37:37 my-app  |     OS: Linux 5.15 Debian GNU/Linux 12 (bookworm) 12 (bookworm)
2024-01-03 10:37:37 my-app  |     CPU: (12) x64 AMD Ryzen 5 4600H with Radeon Graphics
2024-01-03 10:37:37 my-app  |     Memory: 5.12 GB / 7.45 GB
2024-01-03 10:37:37 my-app  |     Container: Yes
2024-01-03 10:37:37 my-app  |     Shell: 5.2.15 - /bin/bash
2024-01-03 10:37:37 my-app  |   Binaries:
2024-01-03 10:37:37 my-app  |     Node: 20.10.0 - /usr/local/bin/node
2024-01-03 10:37:37 my-app  |     Yarn: 1.22.19 - /usr/local/bin/yarn
2024-01-03 10:37:37 my-app  |     npm: 10.2.3 - /usr/local/bin/npm
2024-01-03 10:37:37 my-app  |   npmPackages:
2024-01-03 10:37:37 my-app  |     @vitejs/plugin-vue: ^4.5.2 => 4.5.2 
2024-01-03 10:37:37 my-app  |     vite: ^5.0.10 => 5.0.10

Used Package Manager

npm

Logs

2024-01-03 11:02:35 my-app  | 
2024-01-03 11:02:35 my-app  | > my-app@0.6.0 dev
2024-01-03 11:02:35 my-app  | > npx vite
2024-01-03 11:02:35 my-app  | 
2024-01-03 11:02:37 my-app  | /usr/src/app/node_modules/rollup/dist/native.js:87
2024-01-03 11:02:37 my-app  |             throw new Error(
2024-01-03 11:02:37 my-app  |                   ^
2024-01-03 11:02:37 my-app  | 
2024-01-03 11:02:37 my-app  | Error: Cannot find module @rollup/rollup-linux-x64-gnu. 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.
2024-01-03 11:02:37 my-app  |     at requireWithFriendlyError (/usr/src/app/node_modules/rollup/dist/native.js:87:9)
2024-01-03 11:02:37 my-app  |     at Object.<anonymous> (/usr/src/app/node_modules/rollup/dist/native.js:96:48)
2024-01-03 11:02:37 my-app  |     ... 3 lines matching cause stack trace ...
2024-01-03 11:02:37 my-app  |     at Module._load (node:internal/modules/cjs/loader:1023:12)
2024-01-03 11:02:37 my-app  |     at cjsLoader (node:internal/modules/esm/translators:345:17)
2024-01-03 11:02:37 my-app  |     at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:294:7)
2024-01-03 11:02:37 my-app  |     at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
2024-01-03 11:02:37 my-app  |     at async ModuleLoader.import (node:internal/modules/esm/loader:329:24) {
2024-01-03 11:02:37 my-app  |   [cause]: Error: Cannot find module '@rollup/rollup-linux-x64-gnu'
2024-01-03 11:02:37 my-app  |   Require stack:
2024-01-03 11:02:37 my-app  |   - /usr/src/app/node_modules/rollup/dist/native.js
2024-01-03 11:02:37 my-app  |       at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
2024-01-03 11:02:37 my-app  |       at Module._load (node:internal/modules/cjs/loader:985:27)
2024-01-03 11:02:37 my-app  |       at Module.require (node:internal/modules/cjs/loader:1235:19)
2024-01-03 11:02:37 my-app  |       at require (node:internal/modules/helpers:176:18)
2024-01-03 11:02:37 my-app  |       at requireWithFriendlyError (/usr/src/app/node_modules/rollup/dist/native.js:69:10)
2024-01-03 11:02:37 my-app  |       at Object.<anonymous> (/usr/src/app/node_modules/rollup/dist/native.js:96:48)
2024-01-03 11:02:37 my-app  |       at Module._compile (node:internal/modules/cjs/loader:1376:14)
2024-01-03 11:02:37 my-app  |       at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
2024-01-03 11:02:37 my-app  |       at Module.load (node:internal/modules/cjs/loader:1207:32)
2024-01-03 11:02:37 my-app  |       at Module._load (node:internal/modules/cjs/loader:1023:12) {
2024-01-03 11:02:37 my-app  |     code: 'MODULE_NOT_FOUND',
2024-01-03 11:02:37 my-app  |     requireStack: [ '/usr/src/app/node_modules/rollup/dist/native.js' ]
2024-01-03 11:02:37 my-app  |   }
2024-01-03 11:02:37 my-app  | }
2024-01-03 11:02:37 my-app  | 
2024-01-03 11:02:37 my-app  | Node.js v20.10.0
my-app exited with code 1

Validations

Activity

  1. bolt-new-by-stackblitz commented on Jan 3, 2024

    @bolt-new-by-stackblitz
  2. 0xBeycan commented on Jan 3, 2024

    @0xBeycan
    Author

    If i try yarn rollup fixing but esbuild giving error :D

    yarn run v1.22.19
    $ vite
    2024-01-03 12:45:46 my-app  | failed to load config from /usr/src/app/vite.config.js
    2024-01-03 12:45:46 my-app  | error when starting dev server:
    2024-01-03 12:45:46 my-app  | Error: 
    2024-01-03 12:45:46 my-app  | You installed esbuild for another platform than the one you're currently using.
    2024-01-03 12:45:46 my-app  | This won't work because esbuild is written with native code and needs to
    2024-01-03 12:45:46 my-app  | install a platform-specific binary executable.
    2024-01-03 12:45:46 my-app  | 
    2024-01-03 12:45:46 my-app  | Specifically the "@esbuild/win32-x64" package is present but this platform
    2024-01-03 12:45:46 my-app  | needs the "@esbuild/linux-x64" package instead. People often get into this
    2024-01-03 12:45:46 my-app  | situation by installing esbuild on Windows or macOS and copying "node_modules"
    2024-01-03 12:45:46 my-app  | into a Docker image that runs Linux, or by copying "node_modules" between
    2024-01-03 12:45:46 my-app  | Windows and WSL environments.
    2024-01-03 12:45:46 my-app  | 
    2024-01-03 12:45:46 my-app  | If you are installing with npm, you can try not copying the "node_modules"
    2024-01-03 12:45:46 my-app  | directory when you copy the files over, and running "npm ci" or "npm install"
    2024-01-03 12:45:46 my-app  | on the destination platform after the copy. Or you could consider using yarn
    2024-01-03 12:45:46 my-app  | instead of npm which has built-in support for installing a package on multiple
    2024-01-03 12:45:46 my-app  | platforms simultaneously.
    2024-01-03 12:45:46 my-app  | 
    2024-01-03 12:45:46 my-app  | If you are installing with yarn, you can try listing both this platform and the
    2024-01-03 12:45:46 my-app  | other platform in your ".yarnrc.yml" file using the "supportedArchitectures"
    2024-01-03 12:45:46 my-app  | feature: https://yarnpkg.com/configuration/yarnrc/#supportedArchitectures
    2024-01-03 12:45:46 my-app  | Keep in mind that this means multiple copies of esbuild will be present.
    2024-01-03 12:45:46 my-app  | 
    2024-01-03 12:45:46 my-app  | Another alternative is to use the "esbuild-wasm" package instead, which works
    2024-01-03 12:45:46 my-app  | the same way on all platforms. But it comes with a heavy performance cost and
    2024-01-03 12:45:46 my-app  | can sometimes be 10x slower than the "esbuild" package, so you may also not
    2024-01-03 12:45:46 my-app  | want to do that.
    2024-01-03 12:45:46 my-app  | 
    2024-01-03 12:45:46 my-app  |     at generateBinPath (/usr/src/app/node_modules/esbuild/lib/main.js:1910:17)
    2024-01-03 12:45:46 my-app  |     at esbuildCommandAndArgs (/usr/src/app/node_modules/esbuild/lib/main.js:1991:33)
    2024-01-03 12:45:46 my-app  |     at ensureServiceIsRunning (/usr/src/app/node_modules/esbuild/lib/main.js:2162:25)
    2024-01-03 12:45:46 my-app  |     at build (/usr/src/app/node_modules/esbuild/lib/main.js:2047:26)
    2024-01-03 12:45:46 my-app  |     at bundleConfigFile (file:///usr/src/app/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:67897:26)
    2024-01-03 12:45:46 my-app  |     at loadConfigFromFile (file:///usr/src/app/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:67873:31)
    2024-01-03 12:45:46 my-app  |     at resolveConfig (file:///usr/src/app/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:67475:34)
    2024-01-03 12:45:46 my-app  |     at _createServer (file:///usr/src/app/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:59972:26)
    2024-01-03 12:45:46 my-app  |     at createServer (file:///usr/src/app/node_modules/vite/dist/node/chunks/dep-R0I0XnyH.js:59969:12)
    2024-01-03 12:45:46 my-app  |     at CAC.<anonymous> (file:///usr/src/app/node_modules/vite/dist/node/cli.js:764:30)
    error Command failed with exit code 1.
    info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
    my-app exited with code 1
    
  3. Lymah123 commented on Jan 3, 2024

    @Lymah123

    Hi- Has anyone started working on this issue?

  4. 0xBeycan commented on Jan 4, 2024

    @0xBeycan
    Author

    @Lymah123 You can change package manager to yarn and this line add to package.json

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

    and for vite.config.js you can try this

    export default defineConfig({
      // Other Vite config options...
      esbuild: {
        target: 'esnext',
        platform: 'linux',
      }
      // Other Vite config options...
    });
    

    Can you confirm is works or not for you?

  5. Lymah123 commented on Jan 5, 2024

    @Lymah123

    @Lymah123 You can change package manager to yarn and this line add to package.json

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

    and for vite.config.js you can try this

    export default defineConfig({
      // Other Vite config options...
      esbuild: {
        target: 'esnext',
        platform: 'linux',
      }
      // Other Vite config options...
    });
    

    Can you confirm is works or not for you?

    Hi @BeycanDeveloper, sorry for the late response. I will check it out and let you know.

  6. locked and limited conversation to collaborators on Jan 7, 2024
  7. converted this issue into a discussion #15532 on Jan 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions