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

Cannot find module @rollup/rollup-linux-x64-musl #62

Closed
IgordeOliveira opened this issue Feb 17, 2024 · 5 comments · Fixed by #63
Closed

Cannot find module @rollup/rollup-linux-x64-musl #62

IgordeOliveira opened this issue Feb 17, 2024 · 5 comments · Fixed by #63
Labels
question Further information is requested

Comments

@IgordeOliveira
Copy link

IgordeOliveira commented Feb 17, 2024

Thanks for the project! I'm learning a lot. I wanted to report an issue with the Vite build. I'm still trying to solve it, but here are the logs:

Laravel 10 + Filament

 => ERROR [laravel build 7/7] RUN npm run build                                                                                                                                                                                                0.7s 
------
 > [laravel build 7/7] RUN npm run build:
0.547
0.547 > build
0.547 > vite build
0.547
0.661 /var/www/html/node_modules/rollup/dist/native.js:87
0.661           throw new Error(
0.661                 ^
0.661
0.661 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.  
0.661     at requireWithFriendlyError (/var/www/html/node_modules/rollup/dist/native.js:87:9)
0.661     at Object.<anonymous> (/var/www/html/node_modules/rollup/dist/native.js:96:76)
0.661     ... 3 lines matching cause stack trace ...
0.661     at Module._load (node:internal/modules/cjs/loader:1023:12)
0.661     at cjsLoader (node:internal/modules/esm/translators:356:17)
0.661     at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:305:7)
0.661     at ModuleJob.run (node:internal/modules/esm/module_job:218:25)
0.661     at async ModuleLoader.import (node:internal/modules/esm/loader:329:24) {
0.661   [cause]: Error: Cannot find module '@rollup/rollup-linux-x64-musl'
0.661   Require stack:
0.661   - /var/www/html/node_modules/rollup/dist/native.js
0.661       at Module._resolveFilename (node:internal/modules/cjs/loader:1144:15)
0.661       at Module._load (node:internal/modules/cjs/loader:985:27)
0.661       at Module.require (node:internal/modules/cjs/loader:1235:19)
0.661       at require (node:internal/modules/helpers:176:18)
0.661       at requireWithFriendlyError (/var/www/html/node_modules/rollup/dist/native.js:69:10)
0.661       at Object.<anonymous> (/var/www/html/node_modules/rollup/dist/native.js:96:76)
0.661       at Module._compile (node:internal/modules/cjs/loader:1376:14)
0.661       at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
0.661       at Module.load (node:internal/modules/cjs/loader:1207:32)
0.661       at Module._load (node:internal/modules/cjs/loader:1023:12) {
0.661     code: 'MODULE_NOT_FOUND',
0.661     requireStack: [ '/var/www/html/node_modules/rollup/dist/native.js' ]
0.661   }
0.661 }
0.661

@smortexa
Copy link
Member

You're welcome! I'm glad it's helpful.

Just install @rollup/rollup-linux-x64-musl as a dev-dependency:

npm i @rollup/rollup-linux-x64-musl --save-dev

Or Add the following line to Dockerfile before installing NPM packages:

RUN npm i @rollup/rollup-linux-x64-musl --save-dev

@smortexa smortexa added the question Further information is requested label Feb 17, 2024
@IgordeOliveira
Copy link
Author

I understand. Does this dependency have any connection to this repository?

@smortexa
Copy link
Member

No, It's about Vite, NPM, and probably Node.js base image.

@IgordeOliveira
Copy link
Author

I managed to solve the issue by removing the "--no-optional" flag from both the "npm install" and "npm ci" commands. It turns out that this was a known bug in NPM, which has been documented in the following issue: npm/cli#4828.

COPY package*.json ./

RUN if [ -f $ROOT/package-lock.json ]; \
    then \
    npm ci --no-optional --loglevel=error --no-audit; \
    else \
    npm install --no-optional --loglevel=error --no-audit; \
    fi

@smortexa
Copy link
Member

Thanks @IgordeOliveira. I made a PR to addressing this issue: #63

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants