tailwindcss icon indicating copy to clipboard operation
tailwindcss copied to clipboard

Error: Cannot find module '../lightningcss.linux-x64-musl.node'

Open therealsras opened this issue 6 months ago • 12 comments

Image I had workaround working. but I see it will solve this but no.

#37 3.296 > next build
#37 3.296
#37 4.772    ▲ Next.js 15.3.1
#37 4.773    - Environments: .env.production
#37 4.840    Creating an optimized production build ...
#37 59.97 Failed to compile.
#37 59.97
#37 59.98 app/layout.tsx
#37 59.98 An error occurred in `next/font`.
#37 59.98
#37 59.98 Error: Cannot find module '../lightningcss.linux-x64-musl.node'
#37 59.98 Require stack:
#37 59.98 - /app/node_modules/lightningcss/node/index.js
#37 59.98 - /app/node_modules/@tailwindcss/node/dist/index.js
#37 59.98 - /app/node_modules/@tailwindcss/postcss/dist/index.js
#37 59.98 - /app/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js
#37 59.98 - /app/node_modules/next/dist/build/webpack/config/blocks/css/index.js
#37 59.98 - /app/node_modules/next/dist/build/webpack/config/index.js
#37 59.98 - /app/node_modules/next/dist/build/webpack-config.js
#37 59.98 - /app/node_modules/next/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js
#37 59.98 - /app/node_modules/next/dist/build/collect-build-traces.js
#37 59.98 - /app/node_modules/next/dist/build/index.js
#37 59.98 - /app/node_modules/next/dist/cli/next-build.js
#37 59.98     at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
#37 59.98     at /app/node_modules/next/dist/server/require-hook.js:55:36
#37 59.98     at Module._load (node:internal/modules/cjs/loader:981:27)
#37 59.98     at Module.require (node:internal/modules/cjs/loader:1231:19)
#37 59.98     at mod.require (/app/node_modules/next/dist/server/require-hook.js:65:28)
#37 59.98     at require (node:internal/modules/helpers:177:18)
#37 59.98     at Object.<anonymous> (/app/node_modules/lightningcss/node/index.js:22:22)
#37 59.98     at Module._compile (node:internal/modules/cjs/loader:1364:14)
#37 59.98     at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
#37 59.98     at Module.load (node:internal/modules/cjs/loader:1203:32)
#37 59.98
#37 59.98 lib/fonts.ts
#37 59.98 An error occurred in `next/font`.
#37 59.98
#37 59.98 Error: Cannot find module '../lightningcss.linux-x64-musl.node'
#37 59.98 Require stack:
#37 59.98 - /app/node_modules/lightningcss/node/index.js
#37 59.98 - /app/node_modules/@tailwindcss/node/dist/index.js
#37 59.98 - /app/node_modules/@tailwindcss/postcss/dist/index.js
#37 59.98 - /app/node_modules/next/dist/build/webpack/config/blocks/css/plugins.js
#37 59.98 - /app/node_modules/next/dist/build/webpack/config/blocks/css/index.js
#37 59.98 - /app/node_modules/next/dist/build/webpack/config/index.js
#37 59.98 - /app/node_modules/next/dist/build/webpack-config.js
#37 59.98 - /app/node_modules/next/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js
#37 59.98 - /app/node_modules/next/dist/build/collect-build-traces.js
#37 59.98 - /app/node_modules/next/dist/build/index.js
#37 59.98 - /app/node_modules/next/dist/cli/next-build.js
#37 59.98     at Module._resolveFilename (node:internal/modules/cjs/loader:1140:15)
#37 59.98     at /app/node_modules/next/dist/server/require-hook.js:55:36
#37 59.98     at Module._load (node:internal/modules/cjs/loader:981:27)
#37 59.98     at Module.require (node:internal/modules/cjs/loader:1231:19)
#37 59.98     at mod.require (/app/node_modules/next/dist/server/require-hook.js:65:28)
#37 59.98     at require (node:internal/modules/helpers:177:18)
#37 59.98     at Object.<anonymous> (/app/node_modules/lightningcss/node/index.js:22:22)
#37 59.98     at Module._compile (node:internal/modules/cjs/loader:1364:14)
#37 59.98     at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
#37 59.98     at Module.load (node:internal/modules/cjs/loader:1203:32)
#37 59.98
#37 59.98
#37 59.98 > Build failed because of webpack errors
#37 60.14 npm notice
#37 60.14 npm notice New major version of npm available! 10.8.2 -> 11.3.0
#37 60.14 npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.3.0
#37 60.14 npm notice To update run: npm install -g [email protected]
#37 60.14 npm notice
#37 ERROR: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1

------
> [web-app-dev builder 5/5] RUN npm run build:
59.98     at Module._extensions..js (node:internal/modules/cjs/loader:1422:10)
59.98     at Module.load (node:internal/modules/cjs/loader:1203:32)
59.98
59.98
59.98 > Build failed because of webpack errors
60.14 npm notice
60.14 npm notice New major version of npm available! 10.8.2 -> 11.3.0
60.14 npm notice Changelog: https://github.com/npm/cli/releases/tag/v11.3.0
60.14 npm notice To update run: npm install -g [email protected]
60.14 npm notice
------
failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1
Error ❌ failed to solve: process "/bin/sh -c npm run build" did not complete successfully: exit code: 1

What version of Tailwind CSS are you using?

For example: v4.1.6

What build tool (or framework if it abstracts the build tool) are you using?

For example: Next.js 15.3.1

What version of Node.js are you using? dockerfile: node:18-alpine

For example: Chrome, Safari, or N/A Ubuntu Docker

therealsras avatar May 09 '25 14:05 therealsras

#15806

therealsras avatar May 09 '25 14:05 therealsras

Hey! Yeah this is expected, we can only fix this for our native extension but your bundler still has issues it seems. In the thread #15806 some folks have had issues with only our binary so we still went ahead with this fix.

I suggest you add the necessary dependency for lightningcss.linux-x64-musl.node manually or update npm to the latest version, see: https://github.com/tailwindlabs/tailwindcss/issues/15806#issuecomment-2853991957

philipp-spiess avatar May 09 '25 14:05 philipp-spiess

Can you clarify what you mean by:

I had workaround working. but I see it will solve this but no.

I wouldn't expect our workaround to make your workaround worse.

philipp-spiess avatar May 09 '25 14:05 philipp-spiess

@philipp-spiess are you saying to upgrade npm version in dockerfile. I can build successfully on Mac Arm. but docker could not

sample from dockerfile

FROM node:18-alpine AS deps

therealsras avatar May 09 '25 14:05 therealsras

Hey! Yeah this is expected, we can only fix this for our native extension but your bundler still has issues it seems. In the thread #15806 some folks have had issues with only our binary so we still went ahead with this fix.

I suggest you add the necessary dependency for lightningcss.linux-x64-musl.node manually or update npm to the latest version, see: #15806 (comment)

are you meaning to keep the optionalDependencies as it was.

therealsras avatar May 09 '25 14:05 therealsras

@philipp-spiess are you saying to upgrade npm version in dockerfile. I can build successfully on Mac Arm. but docker could not

Regardless of the issue I'd recommend that, yes, Node 18 is no longer receiving updates and is "end of life" for example. But that might be a larger change based on what Node APIs you're using

are you meaning to keep the optionalDependencies as it was.

If it worked before then yes, keep it. You should be able to remove the ones oxide and only leave the ones for lightningcss inside.

philipp-spiess avatar May 09 '25 14:05 philipp-spiess

oxide

okay. upgrade node version won't fix this right?

and what 4.1.6 fixed is we can remove ones oxide not lightningcss, and will it also be fixed?

therealsras avatar May 09 '25 14:05 therealsras

okay. upgrade node version won't fix this right?

You will need the latest npm version, I don't know if it will work with older node versions. See https://github.com/npm/cli/releases/tag/v11.3.0

and what 4.1.6 fixed is we can remove ones oxide not lightningcss, and will it also be fixed?

Yeah, Oxide is the library we maintain, Lightningcss is a third-party library so it is not as easy to apply the fix. We might have to add something in the future but ideally this can be fixed upstream. I want to wait first and see if our fix has helped at least somewhat.

Are you able to get it working by adding back only this part?

Image

philipp-spiess avatar May 09 '25 14:05 philipp-spiess

okay. upgrade node version won't fix this right?

You will need the latest npm version, I don't know if it will work with older node versions. See https://github.com/npm/cli/releases/tag/v11.3.0

and what 4.1.6 fixed is we can remove ones oxide not lightningcss, and will it also be fixed?

Yeah, Oxide is the library we maintain, Lightningcss is a third-party library so it is not as easy to apply the fix. We might have to add something in the future but ideally this can be fixed upstream. I want to wait first and see if our fix has helped at least somewhat.

Are you able to get it working by adding back only this part?

Image

Thank you. yes, adding it back, it works.

Image

therealsras avatar May 09 '25 14:05 therealsras

@philipp-spiess if trying lastest npm it will causes problem


#33 [web-app-dev deps 3/6] RUN npm install -g npm@latest
#33 2.860 npm error code EBADENGINE
#33 2.861 npm error engine Unsupported engine
#33 2.861 npm error engine Not compatible with your version of node/npm: [email protected]
#33 2.861 npm error notsup Not compatible with your version of node/npm: [email protected]
#33 2.861 npm error notsup Required: {"node":"^20.17.0 || >=22.9.0"}
#33 2.861 npm error notsup Actual:   {"npm":"10.8.2","node":"v18.20.8"}
#33 2.862 npm error A complete log of this run can be found in: /root/.npm/_logs/2025-05-09T14_54_01_686Z-debug-0.log
#33 ERROR: process "/bin/sh -c npm install -g npm@latest" did not complete successfully: exit code: 1

therealsras avatar May 09 '25 14:05 therealsras

@thatguychrisw yeah seems like it doesn't work with Node 18 anymore. Maybe you can try using node 20 and see if that works? Would be awesome to get confirmation that the npm bugfix actually resolves this issue!

philipp-spiess avatar May 09 '25 15:05 philipp-spiess

@thatguychrisw yeah seems like it doesn't work with Node 18 anymore. Maybe you can try using node 20 and see if that works? Would be awesome to get confirmation that the npm bugfix actually resolves this issue!

yes, right node 20 can build successfully. just there are some warning as below.


#38 DONE 0.1s
#39 [web-app-dev deps 6/6] RUN npm install --omit-dev
#39 0.667 npm warn Unknown cli config "--omit-dev". This will stop working in the next major version of npm.
#39 7.304 npm warn deprecated [email protected]: Rimraf versions prior to v4 are no longer supported
#39 7.803 npm warn deprecated [email protected]: This package is no longer supported.
#39 9.339 npm warn deprecated [email protected]: This module is not supported, and leaks memory. Do not use it. Check out lru-cache if you want a good and tested way to coalesce async requests by a key value, which is much more comprehensive and powerful.
#39 9.919 npm warn deprecated [email protected]: Glob versions prior to v9 are no longer supported
#39 10.03 npm warn deprecated [email protected]: This package is no longer supported.
#39 13.67 npm warn deprecated [email protected]: This package is no longer supported.

therealsras avatar May 09 '25 15:05 therealsras

Same problem on Macbook M1, on "node:22.17.0-bullseye-slim":

Error: Cannot find module '../lightningcss.linux-arm64-gnu.node'

ghostlexly avatar Jul 16 '25 15:07 ghostlexly

This happened to me just now when upgrading npm from 10.9.0 to 11.5.2. Node version 22.12.0, tailwind 4.1.11, for 2 different vite apps in the same monorepo.

I recon some wouldn't want to downgrade npm, but after downgrading again everything works as before.

kfayelun avatar Jul 31 '25 11:07 kfayelun

I just started a new project today using a custom docker compose stack and I am seeing this error. I ensured that npm/node are using the latest images. I checked the npm version and I am seeing 11.6.0

Image

shaqaruden avatar Sep 19 '25 17:09 shaqaruden

This has already been written above but just to clarify: This command should fix the issue for now:

npm install lightningcss-linux-arm64-musl lightningcss-linux-x64-gnu lightningcss-linux-x64-musl --save-optional

fejx avatar Sep 21 '25 07:09 fejx

This has already been written above but just to clarify: This command should fix the issue for now:

npm install lightningcss-linux-arm64-musl lightningcss-linux-x64-gnu lightningcss-linux-x64-musl --save-optional

can you help me explain few days ago, i followed your instructions and it built successfully but now i can not build it anymore

Image Image

Anhnguyenanh123 avatar Sep 29 '25 07:09 Anhnguyenanh123