Closed jjtfsalgado closed 1 year ago
Hi!
I can't repro for now. Do you have any more info on when this happening?
This mostly like an install issue or an issue with SWC directly. What OS are you using?
Hello, I have the same problem using debian 10 typescript ^5.0.2 vite ^4.1.0
The problem it happens when run vite build or server. The solution for me we has remove node_modules and install with yarn.
Did this happen after an update of SWC?
This happend after update typescript, the version @vitejs/plugin-react-swc is "^3.0.0"
That's strange I don't see any related issues on the SWC repo. Did the issue reappear even after a clean install?
This happend after update typescript
That's strange I don't see any related issues on the SWC repo. Did the issue reappear even after a clean install?
I had a project vite + react + typescript
I just updated the typescript to version 5
Hey @ArnaudBarre. To follow up on @jjtfsalgado, here is the machine specs:
OS: Microsoft 11 IDE: WebStorm 2022.3.2 VITE: 4.1.1 TS: 4.8.4
@SANTOrick so you got the error without TS 5?
Can people that have the issue also share their OS, node version and SWC installed version?
OS: macOS Ventura 13.2 (Intel) VITE: 4.2.1 TS: 4.9.3 PLUGIN-REACT-SWC: 3.2.0 NODE: 16.17.0
I got the same error. We have fixed the problem with running this command:
npm i -D @swc/cli @swc/core
In the end just installing swc as described here: https://swc.rs/docs/getting-started
What was the SWC version before and after re-intalling @swc/core
?
The newly installed version of @swc/core that addresses this bug for me is "@swc/core": "^1.3.46", I did not have a before version prior to this, hope this helps!
Probably unrelated but after updating I'm seeing
@vitejs/plugin-react-swc@npm:3.2.0 [f1d40] doesn't provide @swc/helpers (p84c25), requested by @swc/core
vite 4.2.1, swc/core 1.3.46, plugin-react-swc 3.2.0, OSX
Running
vite
we occasionally come across with this error. The way we found to overcome this was to remove node_modules and reinstall it. Do you guys have any ideas what is causing this?![]()
Reinstalled but not working
@ArnaudBarre here the previous and current versions after my command.
Before: @swc/core = 1.3.41 (indirect dependency, we did not install it directly prior to this "fix") @swc/cli is not currently installed
After: @swc/core = 1.3.49 @swc/cli is not needed to fix the problem and can be ignored in the install command
@proddy This was a misconfiguration of peer dependencies, this is now fixed on the latest version
@Tareq1586 You still get the error with the latest version of @swc/core?
npm i -D @swc/cli @swc/core
That worked for me.
@swc/cli
should not be needed.npm i -D @swc/core
will force a new version of @swc/core
to be downloaded, but you can them remove it manually from the package.json because it's still a dependency of this plugin
Hi, just a quick bump - today we've encountered the same issue on a colleague's laptop. The interesting part is why this didn't fail on my machine for the last week or so ..
Updating @vitejs/plugin-react-swc
to latest (eg. npm i -D @vitejs/plugin-react-swc@latest
) fixed everything. No need to install swc locally (npm i -D @swc/cli @swc/core
)
The culprit is actually Vite CLI. Creating a new project with npm create vite@latest
or npm create vite@latest my-vue-app -- --template react-swc-ts
uses the v3.0.0.
"@vitejs/plugin-react-swc": "^3.0.0",
"vite": "^4.2.0"
When starting out a new template, any package manager will install the latest version available (because of the ^
prefix).
I think there is just bad version of the SWC package that was published at some point and the solution is just to force a new version of @swc/core
(direct or indirect by updating the plugin one)
I ran into this same error when: (1) using my Mac to install all packages with yarn
, (2) sharing the node_modules
with a Docker image (which is running Debian), (3) running the vite server via Docker.
I never had this issue when using the babel-based https://github.com/vitejs/vite-plugin-react plugin. I also did not see this error when running the dev server directly from my Mac.
I was able to resolve it temporarily by opening a shell in the Docker image and running a yarn install
, which pointed out that an OS-specific package was missing, which also resulted in a change to @swc/core
:
➤ YN0000: ┌ Fetch step
➤ YN0013: │ @swc/core-linux-x64-gnu@npm:1.3.53 can't be found in the cache and will be fetched from the remote registry
➤ YN0000: └ Completed in 2s 456ms
➤ YN0000: ┌ Link step
➤ YN0008: │ esbuild@npm:0.17.18 must be rebuilt because its dependency tree changed
➤ YN0008: │ @swc/core@npm:1.3.53 [ba08b] must be rebuilt because its dependency tree changed
My .yarnrc.yml
file was specifying the following, which was what esbuild
docs point out should be used when sharing node_modules between platforms https://esbuild.github.io/getting-started/#simultaneous-platforms:
supportedArchitectures:
os:
- current
- linux
But it turns out that's currently not sufficient for SWC https://github.com/swc-project/swc/issues/2898. The workaround suggested there https://github.com/swc-project/swc/issues/2898#issuecomment-1180845472 of adding the following to supportedArchitectures
did the trick, fixing the "Bindings not found" error and Docker-based vite server (no separate yarn install
needed for Docker)!
supportedArchitectures:
os:
- current
- linux
libc:
- current
- glibc
@sjdemartini Yeah this is totally expected because SWC is using native binaries. supportedArchitectures
is not a workaround, that the exact reason why this feature exist in yarn 2+ when using git shared node_modules.
I just encountered this issue but it happens only very recently out of nowhere. The issue happen when:
Edit: The issue is resolved after manually run npm install -D @swc/core
. But before that, I tried to run npm install -D vite-plugin-react-swc@latest
and the error still appears. Looks like manually forcing @swc/core
is required.
In case repro needed, I have just initialized a fresh project and encountered this issue. Exact commands from history
is in README https://github.com/Firfi/vite-74-repro
in later commits, there's results of pnpm i -D @swc/cli @swc/core
committed in
and then a result of rerun of pnpm install -D @swc/core
which changes some files as well.
We noticed this problem after "refreshing" package-lock.json
, which we do by deleting the file, and running npm install
(node_modules
not deleted beforehand). The result is npm
removes all @swc/core-xxxx
entries from the lockfile except the one for the current platform. This causes the Bindings not found
error in Vite's dev server when that lockfile is then used in npm ci
or npm install
on another machine that isn't the same platform as the one that refreshed the lockfile.
See minimal reproduction in GitHub and StackBlitz.
The most reliable workaround I found is to force-install the optional dependencies of @swc/core
as optional dependencies of your own project (only the dep that is supported on your platform is installed):
npm install --force --save-optional \
@swc/core-darwin-arm64 \
@swc/core-darwin-x64 \
@swc/core-linux-arm-gnueabihf \
@swc/core-linux-arm64-gnu \
@swc/core-linux-arm64-musl \
@swc/core-linux-x64-gnu \
@swc/core-linux-x64-musl \
@swc/core-win32-arm64-msvc \
@swc/core-win32-ia32-msvc \
@swc/core-win32-x64-msvc
Then check the resulting lockfile into source control.
@tony19 Seems like a bug in npm. What version of npm are you using?
@ArnaudBarre npm v9.5.0, node v18.14.2
Wow just reproduced with npm 9.5.1. What a bug. Found the issue in npm: https://github.com/npm/cli/issues/4828 1 year old. They seems to don't care and ignore that people are using platform binaries nowdays. Even yarn v1 that is stale was updated to handle this correctly. Between pnpm new algorithm resolution, bun lockfile being totally unmaintainable, yarn v1 being stale, yarn v2 having so much config for simple things and this bug in npm I don't know what to recommend now.
Thanks for finding that issue. That's my exact scenario. I'll try spelunking npm source this weekend and submitting a PR if I can.
In the meantime, I think recommending installing the optional deps somewhere (README?) would be helpful.
Same issue here. Tried npm install -D @swc/core
and npm install -D vite-plugin-react-swc@latest
as someone mentioned up. But it is not working for me.
this is my vite.config.ts
import react from "@vitejs/plugin-react-swc";
import { defineConfig } from "vite";
import basicSsl from "@vitejs/plugin-basic-ssl";
export default defineConfig({
root: "./",
publicDir: "public",
plugins: [react(), basicSsl()],
resolve: {
alias: [{ find: "@", replacement: "/src" }],
},
});
My version
"@vitejs/plugin-react-swc": "^3.0.0",
"vite": "^4.2.0",
Yes, this is https://github.com/npm/cli/issues/4828. The bug happens when npm generates the lockfile with an existing node_modules
that contains platform-specific dependencies. Solution should in all cases be to generate while node_modules
does not exist:
rm -rf node_modules package-lock.json && npm i
I would close and pin this issue in the repo.
Thanks everyone for helping on this. Please go like the npm issue.
See the updated initial comment for solutions to workaround this.
npm i -D @swc/cli @swc/core instalé las dev dependencies npm i -D @swc/cli @swc/core ,pero el error continuaba, luego reinstalé node_modules y se solucionó.
1-click reproduction: https://pr.new/github.com/FossPrime/vslite/tree/repro-swc
I'll submit a PR upstream to work around this
PR got merged. I think the problem should be fix at this toolimg plugins level.
https://github.com/kat-tax/vslite/pull/14 Heres what it took, 2 lines
one to detect web containers, one to import a fallback.
cnpm install --force --save-optional \
> @swc/core \
> @swc/core-darwin-arm64 \
> @swc/core-darwin-x64 \
> @swc/core-linux-arm-gnueabihf \
> @swc/core-linux-arm64-gnu \
> @swc/core-linux-arm64-musl \
> @swc/core-linux-x64-gnu \
> @swc/core-linux-x64-musl \
> @swc/core-win32-arm64-msvc \
> @swc/core-win32-ia32-msvc \
> @swc/core-win32-x64-msvc
✖ Install fail! UnSupportedPlatformError: [@swc/core-darwin-arm64@1.3.64] skip download for reason darwin dont includes your platform android
UnSupportedPlatformError: [@swc/core-darwin-arm64@1.3.64] skip download for reason darwin dont includes your platform android
at download (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/download/npm.js:285:17)
at module.exports (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/download/npm.js:24:22)
at async module.exports (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/download/index.js:19:10)
at async _install (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/install_package.js:122:16)
at async install (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/install_package.js:23:12)
at async _installOne (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/local_install.js:215:15)
at async mapper (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/local_install.js:140:5)
npminstall version: 7.9.0
npminstall argv: /data/data/com.termux/files/usr/bin/node /data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/bin/install.js --fix-bug-versions --china --userconfig=/data/data/com.termux/files/home/.cnpmrc --disturl=https://cdn.npmmirror.com/binaries/node --registry=https://registry.npmmirror.com --force --save-optional @swc/core @swc/core-darwin-arm64 @swc/core-darwin-x64 @swc/core-linux-arm-gnueabihf @swc/core-linux-arm64-gnu @swc/core-linux-arm64-musl @swc/core-linux-x64-gnu @swc/core-linux-x64-musl @swc/core-win32-arm64-msvc @swc/core-win32-ia32-msvc @swc/core-win32-x64-msvc
cnpm install --force --save-optional \ > @swc/core \ > @swc/core-darwin-arm64 \ > @swc/core-darwin-x64 \ > @swc/core-linux-arm-gnueabihf \ > @swc/core-linux-arm64-gnu \ > @swc/core-linux-arm64-musl \ > @swc/core-linux-x64-gnu \ > @swc/core-linux-x64-musl \ > @swc/core-win32-arm64-msvc \ > @swc/core-win32-ia32-msvc \ > @swc/core-win32-x64-msvc ✖ Install fail! UnSupportedPlatformError: [@swc/core-darwin-arm64@1.3.64] skip download for reason darwin dont includes your platform android UnSupportedPlatformError: [@swc/core-darwin-arm64@1.3.64] skip download for reason darwin dont includes your platform android at download (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/download/npm.js:285:17) at module.exports (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/download/npm.js:24:22) at async module.exports (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/download/index.js:19:10) at async _install (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/install_package.js:122:16) at async install (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/install_package.js:23:12) at async _installOne (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/local_install.js:215:15) at async mapper (/data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/lib/local_install.js:140:5) npminstall version: 7.9.0 npminstall argv: /data/data/com.termux/files/usr/bin/node /data/data/com.termux/files/usr/lib/node_modules/cnpm/node_modules/.store/npminstall@7.9.0/node_modules/npminstall/bin/install.js --fix-bug-versions --china --userconfig=/data/data/com.termux/files/home/.cnpmrc --disturl=https://cdn.npmmirror.com/binaries/node --registry=https://registry.npmmirror.com --force --save-optional @swc/core @swc/core-darwin-arm64 @swc/core-darwin-x64 @swc/core-linux-arm-gnueabihf @swc/core-linux-arm64-gnu @swc/core-linux-arm64-musl @swc/core-linux-x64-gnu @swc/core-linux-x64-musl @swc/core-win32-arm64-msvc @swc/core-win32-ia32-msvc @swc/core-win32-x64-msvc
I can reproduce this error on Termux from FreeDroid. Nestbox registers as linux-arm64, while termux requires android-arm64 builds. In Go this is an easy thing to fix... and I've made rust builds on Termux many times before, both lvm and on device.
Termux on Pixel 7:
Nestbox for Pixel 7 running Debian:
finally what we should do to solve this error? when ever i pull a branch i got this error and to fix it i havt to delete node-modules and yarn install to fix it. and some packages dont get install well after this. like redux toolkit
I can confirm I'm experiencing this on an M2 mac. Interestingly enough, I notice data corruption warnings coming from my company's JFrog Artifactory instance, which acts as a reverse proxy out to the NPMJS registry. Was a corrupted build of the SWC Plugin pushed out at some point?
npm WARN tar zlib: invalid block type
npm WARN tarball tarball data for @swc/core-darwin-arm64@https://my-artifactory-url.com/api/npm/npm-my-company/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.66.tgz (sha512-UijJsvuLy73vxeVYEy7urIHksXS+3BdvJ9s9AY+bRMSQW483NO7RLp8g4FdTyJbRaN0BH15SQnY0dcjQBkVuHw==) seems to be corrupted. Trying again.
npm WARN tar zlib: invalid block type
npm WARN tarball tarball data for @swc/core-darwin-arm64@https://my-artifactory-url.com/api/npm/npm-my-company/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.66.tgz (sha512-UijJsvuLy73vxeVYEy7urIHksXS+3BdvJ9s9AY+bRMSQW483NO7RLp8g4FdTyJbRaN0BH15SQnY0dcjQBkVuHw==) seems to be corrupted. Trying again.
Try using the standard @vitejs/plugin-react
plugin instead. Falling back to that from the SWC plugin has unblocked me for now:
// vite.config.ts
import react from '@vitejs/plugin-react';
import { defineConfig } from 'vite';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
server: {
port: 3000,
},
});
clone the repo could be a temp solution.
OS: macOS Ventura 13.2 (Intel) VITE: 4.2.1 TS: 4.9.3 PLUGIN-REACT-SWC: 3.2.0 NODE: 16.17.0
I got the same error. We have fixed the problem with running this command:
npm i -D @swc/cli @swc/core
In the end just installing swc as described here: https://swc.rs/docs/getting-started
my issues: 👽 Taro v3.5.1
Error: Bindings not found at Compiler.transformSync (/node_modules/@swc/core/index.js:249:15)
when start the taro project, it has been this error, when I run 'npm i -D @swc/cli @swc/core', the issue has been solved. Thank you for your answer.
I have exact same problem... error message : bindings not found
I couldn't find a solution for Bindings not found
when using plugin-react-swc
as in the following vite config file
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react-swc'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [react()],
})
Initial the project worked well in my previous laptop but has been failling on my current one and having tried the recommendations posted here , the results was the same. My temporary solution for now was to:
"@vitejs/plugin-react-swc": "^3.0.0",
in the package.json with "@vitejs/plugin-react": "^4.0.0",
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
// https://vitejs.dev/config/ export default defineConfig({ plugins: [react()], })
5. npm install
Termux on Pixel 7:
My Installation is same as these except mine is armv7 so it shows armeabi not found and uses the fallback. Then it results to these if anything wrong happened either during installation or change in project files.
Now the lastest version of @vitejs/plugin-react-swc is 3.3.2, but this problem still happen, can anybody tell me what should I do to solve this error? well I know I can use @vitejs/plugin-react intend, but I just wanna use swc.
go https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170 and download the [ Visual Studio 2015, 2017, 2019, and 2022 ], I try to download x64 version, then remove node_modules and reinstall, it works for me.
Why this issue is closed? I am getting same error with latest vite.
OS: macOS Ventura 13.2 (Intel) VITE: 4.2.1 TS: 4.9.3 PLUGIN-REACT-SWC: 3.2.0 NODE: 16.17.0
I got the same error. We have fixed the problem with running this command:
npm i -D @swc/cli @swc/core
In the end just installing swc as described here: https://swc.rs/docs/getting-started
I just wanted to let you know that it works for me. Using a Macbook Pro on MacOS Sonoma 14.1.1 with Intel processor
Getting this same error. Weirdly enough it behaves differently based on the base docker image of bun. On Apple silicon(arm arch) with Docker desktop.
SWC doesn't work with: oven/bun:1-alpine
SWC works with: oven/bun:1
Had same issue. Come from nowhere. Was actively working on the project and suddenly i got this error.
Params
Fixed by: Deleting the "package-lock.json" file and all "node_modules" folders. and then reinstall.
Just make sure that by deleting the "package-lock.json" and reinstalling doesn't break your dependencies by unintentionally installing/updating to major package versions.
Hey there
If you have this problem, you probably ran into is https://github.com/npm/cli/issues/4828. The bug happens when npm generates the lockfile with an existing node_modules that contains platform-specific dependencies.
Two solutions:
rm -rf node_modules package-lock.json && npm i
Original post
Running
vite
we occasionally come across with this error. The way we found to overcome this was to remove node_modules and reinstall it. Do you guys have any ideas what is causing this?