swc: TypeError: Can not find node binding files from @swc/core-win32-x64-gnu, @swc/core-win32-x64-msvc...

Describe the bug We’ve been using swc on linux and os x machines for a while. Now a colleague tried to build a project on windows and encountered this error:

 C:\Users\xyz\projects\swc-win32> yarn swc
yarn run v1.22.5
$ C:\Users\xyz\projects\swc-win32\node_modules\.bin\swc
C:\Users\xyz\projects\swc-win32\node_modules\@node-rs\helper\lib\loader.js:27
    throw new TypeError(errorMsg);
    ^

TypeError: Can not find node binding files from @swc/core-win32-x64-gnu, @swc/core-win32-x64-msvc and C:\Users\xyz\projects\swc-win32\node_modules\@swc\core\swc.win32-x64-gnu.node, C:\Users\xyz\projects\swc-win32\node_modules\@swc\core\swc.win32-x64-msvc.node
    at Object.loadBinding (C:\Users\xyz\projects\swc-win32\node_modules\@node-rs\helper\lib\loader.js:27:11)
    at Object.<anonymous> (C:\Users\xyz\projects\swc-win32\node_modules\@swc\core\index.js:26:27)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
    at Module.load (internal/modules/cjs/loader.js:928:32)
    at Function.Module._load (internal/modules/cjs/loader.js:769:14)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at Object.<anonymous> (C:\Users\xyz\projects\swc-win32\node_modules\@swc\cli\lib\src\swc\util.js:35:26)
    at Module._compile (internal/modules/cjs/loader.js:1063:30)
error Command failed with exit code 1.

In fact this is copied from my minimal recreation of the same problem inside my Windows 10 VM. But through swc-loader the error was the same.

The files C:\Users\xyz\projects\swc-win32\node_modules\@swc\core\swc.win32-x64-gnu.node and C:\Users\xyz\projects\swc-win32\node_modules\@swc\core\swc.win32-x64-msvc.node do not exist. But the package @swc/core-win32-x64-msvc seems to have been installed:

 ls C:\Users\xyz\projects\swc-win32\node_modules\@swc\     


    Directory: C:\Users\xyz\projects\swc-win32\node_modules\@swc


Mode                 LastWriteTime         Length Name
----                 -------------         ------ ----
d-----         1/22/2021   3:19 PM                cli
d-----         1/22/2021   3:19 PM                core
d-----         1/22/2021   3:19 PM                core-win32-x64-msvc

Input code My minimal example only contains this package.json:

{
  "devDependencies": {
    "@swc/cli": "^0.1.32",
    "@swc/core": "^1.2.45"
  }
}

Config // since this is a minimal example, i don’t have a .swcrc

Expected behavior swc cli to work

Version The version of @swc/core: 1.2.45

Additional context yarn versions says:

yarn versions v1.22.5
{
  yarn: '1.22.5',
  node: '14.15.4',
  v8: '8.4.371.19-node.17',
  uv: '1.40.0',
  zlib: '1.2.11',
  brotli: '1.0.9',
  ares: '1.16.1',
  modules: '83',
  nghttp2: '1.41.0',
  napi: '7',
  llhttp: '2.1.3',
  openssl: '1.1.1i',
  cldr: '37.0',
  icu: '67.1',
  tz: '2020a',
  unicode: '13.0'
}

I would appreciate any help 😃

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 19 (7 by maintainers)

Commits related to this issue

Most upvoted comments

I know this is a bit old, but I had a similar issue yesterday and just wanted to help anyone stumbling upon this thread because of a similar search.

I solved this problem by installing the Visual C++ redistributables: https://learn.microsoft.com/en-us/cpp/windows/latest-supported-vc-redist?view=msvc-170

@tw-360vier delete node_modules and yarn.lock and reinstall, then try again

@Brooooooklyn I updated all my chocolatey packages and now i can’t reproduce it anymore, either.