watcher icon indicating copy to clipboard operation
watcher copied to clipboard

Error: No prebuild or local build of @parcel/watcher found. Tried @parcel/watcher-linux-arm64-musl.

Open mkhvoiko opened this issue 2 years ago • 20 comments

Hello, We have a problem with running gatsby build in pipeline on linux VMs and in Docker. It works only if i run gatsby build locally on my mac with m1. It doesnt work on my mac if i try to run build in docker. It doesnt work in pipeline - both in script and in docker. I tried different base images with different node versions. I tried to run in pipeline with ubuntu 22 - the same result. Dockerfile: FROM node:18.4.0-buster-slim RUN apt-get update && apt-get install -y python3 build-essential gcc g++ make RUN npm install -g gatsby-cli COPY . . RUN npm ci RUN gatsby build Inside the container i see node_modules with @parcel/watcher and all files #151

mkhvoiko avatar Aug 11 '23 14:08 mkhvoiko

` ERROR #11903 API.TYPESCRIPT.COMPILATION

There was an unhandled error during compilation for /. Please run the command with the --verbose flag again. No prebuild or local build of @parcel/watcher found. Tried @parcel/watcher-linux-arm64-glibc. Please ensure it is installed (don't use --no-optional when installing with npm). Otherwise it is possible we don't support your platform yet. If this is the case, please report an issue to https://github.com/parcel-bundler/watcher.

Error: No prebuild or local build of @parcel/watcher found. Tried @parcel/watcher-linux-arm64-glibc. Please ensure it is installed (don't use --no-optional when installing with npm). Otherwise it is possible we don't support your platform yet. If this is the case, please report an issue to https://github.com/parcel-bundler/watcher.

  • index.js:25 Object. /node_modules/@parcel/watcher/index.js:25:13

  • loader:1112 Module._compile node:internal/modules/cjs/loader:1112:14

  • loader:1166 Object.Module._extensions..js node:internal/modules/cjs/loader:1166:10

  • loader:988 Module.load node:internal/modules/cjs/loader:988:32

  • loader:834 Function.Module._load node:internal/modules/cjs/loader:834:12

  • loader:1012 Module.require node:internal/modules/cjs/loader:1012:19

  • helpers:102 require node:internal/modules/cjs/helpers:102:18

  • index.js:7 Object. /node_modules/@parcel/fs/lib/index.js:7:28

  • loader:1112 Module._compile node:internal/modules/cjs/loader:1112:14

  • loader:1166 Object.Module._extensions..js node:internal/modules/cjs/loader:1166:10

  • loader:988 Module.load node:internal/modules/cjs/loader:988:32

  • loader:834 Function.Module._load node:internal/modules/cjs/loader:834:12

  • loader:1012 Module.require node:internal/modules/cjs/loader:1012:19

  • helpers:102 require node:internal/modules/cjs/helpers:102:18

  • LMDBCache.js:49 _fs /node_modules/@parcel/cache/lib/LMDBCache.js:49:16

  • LMDBCache.js:79 new LMDBCache /node_modules/@parcel/cache/lib/LMDBCache.js:79:20

not finished compile gatsby files - 0.101s`

mkhvoiko avatar Aug 11 '23 14:08 mkhvoiko

The package exists https://www.npmjs.com/package/@parcel/watcher-linux-arm64-musl but for some reason (perhaps an npm bug) it may not have been installed properly? Try clearing your package-lock.json and deleting node modules and then re installing. https://github.com/npm/cli/issues/4828

devongovett avatar Aug 24 '23 03:08 devongovett

Can confirm the same thing as the topic starter.

Build log:

 > [builder 5/5] RUN yarn build:
#0 0.501 yarn run v1.22.19
#0 0.553 $ yarn build:sdk && yarn build:hosted
#0 0.798 $ yarn workspace @novoic/storyteller build --log-level=warn
#0 1.365 $ parcel build src/index.tsx --log-level=warn
#0 1.688 Error: No prebuild or local build of @parcel/watcher found. Tried @parcel/watcher-linux-x64-musl. Please ensure it is installed (don't use --no-optional when installing with npm). Otherwise it is possible we don't support your platform yet. If this is the case, please report an issue to https://github.com/parcel-bundler/watcher.
#0 1.688     at Object.<anonymous> (/app/node_modules/@parcel/watcher/index.js:23:13)
#0 1.688     at Module._compile (node:internal/modules/cjs/loader:1159:14)
#0 1.688     at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
#0 1.688     at Module.load (node:internal/modules/cjs/loader:1037:32)
#0 1.688     at Module._load (node:internal/modules/cjs/loader:878:12)
#0 1.688     at Module.require (node:internal/modules/cjs/loader:1061:19)
#0 1.688     at require (node:internal/modules/cjs/helpers:103:18)
#0 1.688     at Object.<anonymous> (/app/node_modules/@parcel/fs/lib/index.js:7:28)
#0 1.688     at Module._compile (node:internal/modules/cjs/loader:1159:14)
#0 1.688     at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
#0 1.815 error Command failed with exit code 1.
#0 1.815 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#0 1.840 error Command failed.
#0 1.840 Exit code: 1
#0 1.840 Command: /usr/local/bin/node
#0 1.840 Arguments: /opt/yarn-v1.22.19/lib/cli.js build --log-level=warn
#0 1.840 Directory: /app/packages/storyteller
#0 1.840 Output:
#0 1.840
#0 1.841 info Visit https://yarnpkg.com/en/docs/cli/workspace for documentation about this command.
#0 1.867 error Command failed with exit code 1.
#0 1.867 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
#0 1.893 error Command failed with exit code 1.
#0 1.893 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
------
Dockerfile:21
--------------------
  19 |     RUN yarn install
  20 |
  21 | >>> RUN yarn build
  22 |
  23 |     FROM nginx:1.23.0-alpine

Used node:18-alpine3.15 as base image. Would appreciate any solutions. At this point it seems that downgrading is the only option

Kureev avatar Aug 26 '23 19:08 Kureev

Did you follow the instructions in the error message? I can't do anything about npm/yarn not installing things properly. Things to try:

  • Verify that the package actually does not exist in your node_modules
  • Verify that you are not installing with --no-optional (npm) or --ignore-optional (yarn)
  • Check that the missing package is listed in your lock file. If not, delete your lock file and node_modules and re-install.

devongovett avatar Aug 26 '23 19:08 devongovett

I just had this issue except with @parcel/watcher-linux-arm-glibc using a Raspberry Pi 4 running Raspberry Pi OS, based on Debian Bullseye. I decided to try using require in the Node REPL to see if it works, and found a more descriptive error: couldn't find glibc 2.32. I checked my system and found I had glibc 2.31 available in the repos. One format to Ubuntu later and I had glibc ~2.37 available and the error is fixed.

Some possibly helpful takeaways from my experience:

  • It seems like the new parcel/watcher distribution system can fail with this Error: No prebuild or local build error and squash a more descriptive error message
  • The new system depends on glibc 2.32, such that some stability-focused distros like Debian can't run it, so check the availability of your repos. Buster is before Bullseye, so you might be hit by the same issue. There may be something similar with musl.
  • You might be able to get a more descriptive error message by using require on the package in question in the REPL or another dummy environment.

Hope this helps you and/or someone else in the future!

rogermparent avatar Sep 06 '23 13:09 rogermparent

Just popped into the code and I found where the message is logged, and indeed parcel will simply log this message in a catch block regardless of why the require failed.

Maybe right off we could tweak the verbiage of the message to something like Error: Failed to load prebuild, and beyond that maybe pass along messages from the caught error? From there it'll be much easier for users to diagnose whatever their own issue is.

rogermparent avatar Sep 06 '23 13:09 rogermparent

Facing the same issue with @parcel/watcher-linux-x64-musl package. Downgrade of parcel or watcher packages did not help

estromenko avatar Sep 08 '23 12:09 estromenko

I just had this issue except with @parcel/watcher-linux-arm-glibc using a Raspberry Pi 4 running Raspberry Pi OS, based on Debian Bullseye. I decided to try using require in the Node REPL to see if it works, and found a more descriptive error: couldn't find glibc 2.32. I checked my system and found I had glibc 2.31 available in the repos. One format to Ubuntu later and I had glibc ~2.37 available and the error is fixed.

Some possibly helpful takeaways from my experience:

  • It seems like the new parcel/watcher distribution system can fail with this Error: No prebuild or local build error and squash a more descriptive error message
  • The new system depends on glibc 2.32, such that some stability-focused distros like Debian can't run it, so check the availability of your repos. Buster is before Bullseye, so you might be hit by the same issue. There may be something similar with musl.
  • You might be able to get a more descriptive error message by using require on the package in question in the REPL or another dummy environment.

Hope this helps you and/or someone else in the future!

I recently ran into a similar issue on a netlify container. We (temporarily) resolved it by manually adding '@parcel/watcher-linux-x64-glibc' as an optional dependency.

felixhauptmann avatar Sep 09 '23 13:09 felixhauptmann

Facing the same issue with @parcel/watcher-linux-x64-musl package. Downgrade of parcel or watcher packages did not help

Solved the problem upgrading alpine from 3.15 to 3.18.

To reproduce the issue run commands below (the second one is failing)

docker run --rm -it node:18-alpine3.18 sh -c "yarn add parcel && echo 123 >> index.tsx && yarn parcel build index.tsx"
docker run --rm -it node:18-alpine3.15 sh -c "yarn add parcel && echo 123 >> index.tsx && yarn parcel build index.tsx"

estromenko avatar Sep 11 '23 10:09 estromenko

Why is a filesystem watcher needed to do an one-shot build of a project?

dgadelha avatar Dec 11 '23 15:12 dgadelha

This package also allows detecting changes between one-shot builds: https://github.com/parcel-bundler/watcher#querying

mischnic avatar Dec 11 '23 15:12 mischnic

I experienced this issue using the electron-forge typescript-webpack template trying to use @parcel/watcher at runtime.

The error message reported the correct package name, however, inspecting the build output showed webpack was only interpreting the name to require as -glibc instead of appending that to the existing name.

[electron] Error: Cannot find module '-glibc'
[electron]     at webpackMissingModule (/home/shamsup/projects/electron-test/.webpack/main/index.js:27:82)

I am not familiar enough with webpack internals to explain why it misinterprets the require, but this patch resolved the issue (patch-package):

diff --git a/node_modules/@parcel/watcher/index.js b/node_modules/@parcel/watcher/index.js
index 4929c54..64dd688 100644
--- a/node_modules/@parcel/watcher/index.js
+++ b/node_modules/@parcel/watcher/index.js
@@ -4,9 +4,9 @@ let name = `@parcel/watcher-${process.platform}-${process.arch}`;
 if (process.platform === 'linux') {
   const { MUSL, family } = require('detect-libc');
   if (family === MUSL) {
-    name += '-musl';
+    name = `@parcel/watcher-${process.platform}-${process.arch}-musl`;
   } else {
-    name += '-glibc';
+    name = `@parcel/watcher-${process.platform}-${process.arch}-glibc`;
   }
 }

shamsup avatar Dec 30 '23 00:12 shamsup

I ran into a very similar issue and got around it by:

  • adding @parcel/watcher-linux-x64-glibc into optionalDependencies in package.json
    • npm install -O @parcel/watcher-linux-x64-glibc
  • running npm dedupe
  • 💰

theprivileges avatar Jan 03 '24 23:01 theprivileges

ran into this same issue. @theprivileges solution worked for me. This was in a github action where I was having the issue.

paceaux avatar Feb 06 '24 16:02 paceaux

I have exact same issue with building on node:alpine

Error: No prebuild or local build of @parcel/watcher found. Tried @parcel/watcher-linux-x64-musl.
Please ensure it is installed (don't use --no-optional when installing with npm).
Otherwise it is possible we don't support your platform yet. If this is the case,
please report an issue to https://github.com/parcel-bundler/watcher

OzzyCzech avatar Aug 23 '24 16:08 OzzyCzech

I was able to solve this by adding npm install @parcel/watcher or whatever is suggested by error message after your npm install command.

RUN npm ci

RUN npm install @parcel/watcher

RUN npm run build

abhimanyu7dev avatar Aug 27 '24 12:08 abhimanyu7dev

I had this problem with a GitHub action (reported here), and using npm dedupe resolved it.

imnasnainaec avatar Sep 25 '24 18:09 imnasnainaec

I do my development on Windows and then build using Docker with the node:20 image before deploying to Linux. If the package-lock.json file generated by npm install on Windows exists, the build will fail when running in Docker. However, if I delete this file and run npm install again inside Docker, the build will succeed.

Update:

When on Windows, after deleting node_modules and package-lock.json and reinstalling, using npm ci again in Docker worked successfully.

zhaoxuyll avatar Apr 22 '25 02:04 zhaoxuyll

Netlify users:

I added a postinstall script that installs @parcel/watcher-linux-x64-glibc when the $NETLIFY env var is set to true (Netlify sets this automatically when building), and that did the trick.

"postinstall": "if [ \"$NETLIFY\" = \"true\" ]; then npm i @parcel/watcher-linux-x64-glibc --no-save || true; fi"

If it still fails, delete package-lock and reinstall, push, then clear the cache in Netlify to rebuild fresh.

For non-Netlify users, try conditionally installing that dependency in your deploy environment and see if that fixes it.

justinmahar avatar Oct 11 '25 13:10 justinmahar

strange… once i run into this issue, no matter what i do, it won't go away, utill i downgrade to ~2.1.0 as this comment suggest. but after i succes once, the problem can not reproduce again...

I HATE GHOST PROBLEM.

Inori-Lover avatar Nov 04 '25 10:11 Inori-Lover