parcel-bundler / watcher

👀 A native C++ Node module for querying and subscribing to filesystem events
MIT License
656 stars 45 forks source link

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

Open mkhvoiko opened 1 year ago

mkhvoiko commented 1 year ago

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 commented 1 year ago

` 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.

not finished compile gatsby files - 0.101s`

devongovett commented 1 year ago

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

Kureev commented 1 year ago

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

devongovett commented 1 year ago

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

rogermparent commented 1 year ago

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:

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

rogermparent commented 1 year ago

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.

estromenko commented 1 year ago

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

felixhauptmann commented 1 year ago

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.

estromenko commented 1 year ago

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"
dgadelha commented 9 months ago

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

mischnic commented 9 months ago

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

shamsup commented 9 months ago

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`;
   }
 }
theprivileges commented 9 months ago

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

paceaux commented 8 months ago

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

OzzyCzech commented 1 month ago

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
abhimanyu7dev commented 1 month ago

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
imnasnainaec commented 1 week ago

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