swc: @swc/core threw an error when attempting to validate swc compiler options.
Describe the bug
Hi there,
I am using @swc/core
to speedup the execution of my test suite with avajs/ava.
System info: Ubuntu 20.04.1 (VM via parallels 18 on a Mac Mini Intel) node 16.15.0
During npm run test
I receive the following error, and I am not sure how to resolve the issue.
/home/st/actions-runner/_work/snow/snow/node_modules/ts-node/src/transpilers/swc.ts:262
throw new Error(
^
Error: @swc/core threw an error when attempting to validate swc compiler options.
You may be using an old version of swc which does not support the options used by ts-node.
Try upgrading to the latest version of swc.
Error message from swc:
Bindings not found
at createVariant (/home/st/actions-runner/_work/snow/snow/node_modules/ts-node/src/transpilers/swc.ts:262:13)
at createSwcOptions (/home/st/actions-runner/_work/snow/snow/node_modules/ts-node/src/transpilers/swc.ts:211:25)
at create (/home/st/actions-runner/_work/snow/snow/node_modules/ts-node/src/transpilers/swc.ts:56:41)
at createTranspiler (/home/st/actions-runner/_work/snow/snow/node_modules/ts-node/src/index.ts:784:16)
at createTranspileOnlyGetOutputFunction (/home/st/actions-runner/_work/snow/snow/node_modules/ts-node/src/index.ts:1341:28)
at createFromPreloadedConfig (/home/st/actions-runner/_work/snow/snow/node_modules/ts-node/src/index.ts:1404:34)
at create (/home/st/actions-runner/_work/snow/snow/node_modules/ts-node/src/index.ts:624:10)
at register (/home/st/actions-runner/_work/snow/snow/node_modules/ts-node/src/index.ts:591:15)
at Object.registerAndCreateEsmHooks (/home/st/actions-runner/_work/snow/snow/node_modules/ts-node/src/esm.ts:116:34)
at file:///home/st/actions-runner/_work/snow/snow/node_modules/ts-node/esm.mjs:8:7
✖ test/1.sys.test.ts exited with a non-zero exit code: 1
Input code
No response
Config
Snippet of tsconfig.json
config:
"ts-node": {
"swc": true
},
Playground link
No response
Expected behavior
Successful execution of npm run test
.
Actual behavior
No response
Version
v1.2.241
Additional context
No response
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 17
- Comments: 60 (9 by maintainers)
Commits related to this issue
- chore: rebuild lock file as per https://github.com/swc-project/swc/issues/5616 — committed to ImLunaHey/ticket-genie by ImLunaHey a year ago
- Support React 18 (#423) The following changes were made to support React 18: - Updated `react` and `react-dom` dev dependency versions from 17.0.2 to 18.2.0 - Updated peer dependencies to allow Rea... — committed to yext/search-ui-react by jesuyedavid 4 months ago
adding the core modules as optional dependencies for the project fixed the error for me:
you can also filter out the list of packages in case you are certain what is the OS / architecture of your development computer and the CI.
hope this helps for others until the issue is resolved!
I’m having this issue re-appear with
@swc/core@1.3.83
(and@swc/core@1.3.84
) on Linux (Debian 12) with a mono repo using npm. If I explicitly install@swc/core@1.3.83
(or@swc/core@latest
) in my workspace it doesn’t work but explicitly installing the previous version i.e.,npm -w=backend i -D @swc/core@1.3.82
, is a good workaround for now.EDIT: My issue is actually a ts-node issue. See: https://github.com/TypeStrong/ts-node/issues/2059 https://github.com/TypeStrong/ts-node/issues/2056
I’ve ran into similar issue with a bit uncommon setup, but maybe this will help shed some light.
I have a working setup on local node 18, using yarn (on intel mac). I wanted to create a sample Dockerfile using npm, so I ran
npm i
locally to generatepackage-lock.json
. Then docker build ran up to the build point where it failed onFallback bindings does not support filesystem access.
. When installing@swc/core
and@swc-cli
in the build step in the container again, it worked well.Then I removed
node_modules
andpackage-lock.json
on the host and rannpm i
again to get a newpackage-lock.json
. And with this new lock the whole build ran successfully.old-package-lock.json.txt package-lock.json.txt
When compared, there are few
@swc
packages that didn’t get “locked” with existing node_modules.So, maybe the “work-around” is to
rm -rf node_modules && rm package-lock.json && npm i
on the host?Also, on host I have
cli
,core
,core-darwin-x64
innode_modules/@swc
. When I ranls
in the broken-build image, I gotcli
,core
,wasm
with the old-package-lock.json. With the new, working lock I havecore-linux-x64-gnu
andcore-linux-x64-musl
in there instead. Docker image is based onnode:18-slim
.@btecu @Bluzzi My co-worker found a fix for this, inside
.yarnrc.yml
. Both of us are using M1 Pro MacBook Pros and his worked without this addition, but for some reason mine had the errorthrow new Error("Bindings not found");
The solution was to put
- arm64
undercpu
. Full output of.yarnrc.yml
.I don’t know if it’ll solve your guy’s problems, but it did solve mine!
I’m also running into this issue after updating from
node 14.17.1
tonode 16.16.0
on a MBP 16 M1 Pro:This issue is still valid
I can work around this by simply
yarn add -D @swc/core@latest
.What helped me in my npm monorepo:
npm uninstall
allswc
related packagespackage-lock.json
node_modules
directoriesnpm install
npm install
theswc
related packages againI was having the same issue
Fallback bindings does not support filesystem access.
when running in GitHub Actions.@pcdevil 's response solved the issue - thanks!!
What have helped me
@swc/core
of needed version therecore-darwin-x64
tonode_modules/@swc
thanks @pcdevil that was the solution for me (when compiling react-email in docker)
Same problem. Runs fine on MacOS in local env and throws while building on Docker.
The workaround is use
pnpm
. It is not desired on our project but it passes…Not sure why bot aggressively marks this one 🤔
I put it again here, in case it helps someone.
pnpm
solved the build on CI, but my coworker is unable to run the project on Ubuntu (Node v18.16.0)@kwonoj well, we are sharing project among people with MacOS, Windows, Ubuntu but this is a normal situation when repo has collaborators
this issue is annoying I have to install swc manually each time after
npm i
, does anybody found a way to fix it once for all?Indeed this solution is working well when I run
npx jest "file"
, btw installing@swc/core
is enough and solves the problem, but I’m Interested if there are other dependencies that require it.I have the same issue when I use Github action on @swc/core 1.3.44. I try to downgrade to @swc/core 1.3.39.The action work again.
This is exactly what I did and it solved the issue.
I ran into a similar problem when running a build with SWC in GitHub actions (worked fine on my M1 mac).
The build would fail with
Fallback bindings does not support filesystem access.
After upgrading @swc/cli to 0.1.62 and @swc/core to 1.3.39 the build executed again in my workflow.
@littleski I ran into the same problem and adding
@swc/wasm
solved it for me too…so yes, a bug in the post install maybe?I think there is a bug in the postinstall.sh script in the swc module. Somewhere, it “trash” the @swc/wasm module instead of adding it. the script however is discarded if @swc/wasm is added in the dependencies. What fixed it for me (in my dockers in CI), is to add the package in the dependencies. But looking at the comments, i think there is multiple issues listed here, so it may not fix for everyone.
Hey buddy, I have encountered the same issue as you and have solved it, I would like to share my experience with you to see if it can help. Just a few days ago I was able to install Taro-cli without any issues, then after reinstalling the system, my project encountered the same error as yours. I searched for solutions in the Taro repository and the SWC repository, but there was no ready answer. However, they gave some directions to troubleshoot.So I tried switching the node version, package manager version and source, and Taro/cli version, but all failed. Finally, I debugged the source code with breakpoints, combined with my own experience, and found that the problem was related to the rust runtime environment, which needed to be installed. The specific installation method can be referred to the link below. https://blog.csdn.net/u011149152/article/details/123518465
This issue has been automatically closed because it received no activity for a month and had no reproduction to investigate. If you think this was closed by accident, please leave a comment. If you are running into a similar issue, please open a new issue with a reproduction. Thank you.