parcel: Could not resolve module @parcel/css/parcel-css.linux-x64-musl.node

πŸ› bug report

Building...
🚨 Build failed.

@parcel/transformer-css: Could not resolve module
"/home/node/application/node_modules/@parcel/css/parcel-css.linux-x64-musl.node"
from "/home/node/application/node_modules/@parcel/css/node/index.js"

πŸŽ› Configuration (.babelrc, package.json, cli command)

CLI command:

$ parcel index.html

πŸ€” Expected Behavior

The build should succeed.

😯 Current Behavior

When running the command inside Docker:

$ parcel index.html

I get the following error:

Error: Could not resolve module
"/home/node/application/node_modules/@parcel/css/parcel-css.linux-x64-musl.node"
from "/home/node/application/node_modules/@parcel/css/node/index.js"
at $0578d0f6e116167e$export$fb2a0b866a8162dc.resolve
(/home/node/application/node_modules/@parcel/package-manager/lib/index.js:4919:21)
at NodePackageManager.resolveSync
(/home/node/application/node_modules/@parcel/package-manager/lib/index.js:3510:42)
at NodePackageManager.requireSync
(/home/node/application/node_modules/@parcel/package-manager/lib/index.js:3351:34)
at Module.m.require
(/home/node/application/node_modules/@parcel/package-manager/lib/index.js:3365:25)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous>
(/home/node/application/node_modules/@parcel/css/node/index.js:21:22)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at NodePackageManager.load
(/home/node/application/node_modules/@parcel/package-manager/lib/index.js:3374:15)

πŸ’ Possible Solution

No idea.

πŸ”¦ Context

I am running everything here inside a fermium-alpine Docker environment, although the same happens in a node:gallium-alpine environment.

I started seeing the issue about a week ago, maybe a little less, There is also a Pull Request available with everything at latest here.

πŸ’» Code Sample

The full codebase can be seen at small-glade. You can just run docker-compose up.

🌍 Your Environment

A node:gallium-alpine Docker environment.

Software Version(s)
Parcel 2.4.0
Node 14.19.1
npm/Yarn npm 6.14.16
Operating System Alpine

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 15 (5 by maintainers)

Commits related to this issue

Most upvoted comments

I encountered this issue as well.

When I run npm install @parcel/css, I see the packages for all platforms listed in package-lock.json. What version of npm are you using?

Simply running npm install --save-dev @parcel/css fixed the issue in the CI pipeline.

Hey @afitzgerald, I think that @devongovett is correct here.

My situation is maybe a bit strange. Like I said, the steps I followed to get to this issue are:

  1. Install dependencies locally on my machine (MacOS).
  2. Copy package.json and package-lock.json into an Alpine container (source).
  3. Install dependencies inside the Alpine container (source) with the above lock-file.

Thus the lock-file says that @parcel/transformer-css is not required as it was generated on MacOS but then I am installing dependencies on Alpine which does require @parcel/transformer-css.

The weirdness here is that it worked a week or two ago and now doesn’t and I cannot quite pinpoint what updated to cause this change. I initially thought it was something that parcel changed, but I am now doubting that.

Okay πŸŽ‰ Thanks to your replies I have managed to find the issue.

Inside the container I was running npm install --no-optional. I changed it to npm install which has now resolved the issue.

I am thinking that because the package-lock.json file is generated outside of the container that the dependency mentioned above is optional, and then got skipped while building the container.

I am still unsure of what exactly changed, as this had been working for months before, but I guess that isn’t important now.

Thank you for your time.

When I run npm install @parcel/css, I see the packages for all platforms listed in package-lock.json. What version of npm are you using?

I don’t believe that requiring the removal of --no-optional should be the solution for this. Parcel should call out @parcel/transformer-css as a required dependency.