nx: Failed to load plugin '@nrwl/nx' declared in 'apps/project/.eslintrc.json » ../../../.eslintrc.js#overrides[1]': Cannot find module '@swc/core-linux-x64-gnu'
Current Behavior
Since the upgrade the Nrwl 13+, when I run the affected lint target on the CI (azure devops), I got this error on all projects:
Failed to load plugin '@nrwl/nx' declared in 'apps/shared-ui-e2e/.eslintrc.json » ../../../.eslintrc.js#overrides[1]': Cannot find module '@swc/core-linux-x64-gnu'
Require stack:
- /var/vsts/temporary-agent-grizzly-l4j54/1/s/node_modules/@swc/core/binding.js
- /var/vsts/temporary-agent-grizzly-l4j54/1/s/node_modules/@swc/core/index.js
- /var/vsts/temporary-agent-grizzly-l4j54/1/s/node_modules/@swc-node/core/lib/index.js
- /var/vsts/temporary-agent-grizzly-l4j54/1/s/node_modules/@swc-node/register/lib/register.js
- /var/vsts/temporary-agent-grizzly-l4j54/1/s/node_modules/@nrwl/eslint-plugin-nx/src/resolve-workspace-rules.js
- /var/vsts/temporary-agent-grizzly-l4j54/1/s/node_modules/@nrwl/eslint-plugin-nx/src/index.js
- /var/vsts/temporary-agent-grizzly-l4j54/1/s/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
Referenced from: /var/vsts/temporary-agent-grizzly-l4j54/1/s/.eslintrc.js
I already put a comment on this closed issue: #8735. @meeroslav also made a PR #8831 that should fix the issue on 13.7.3 but I am still having it.
For the moment I have to install the library each time I run a lint command on the CI:
yarn add @swc/core-linux-x64-gnu --dev
But this is increasing a lot of the time to the CI process
Expected Behavior
To not have this error
Steps to Reproduce
yarn affected:lint
Environment
Node : 16.13.1
OS : darwin x64
yarn : 1.22.17
nx : 13.8.1
@nrwl/angular : 13.8.1
@nrwl/cli : 13.8.1
@nrwl/cypress : 13.8.1
@nrwl/detox : undefined
@nrwl/devkit : 13.8.1
@nrwl/eslint-plugin-nx : 13.8.1
@nrwl/express : undefined
@nrwl/jest : 13.8.1
@nrwl/js : 13.8.1
@nrwl/linter : 13.8.1
@nrwl/nest : undefined
@nrwl/next : undefined
@nrwl/node : 13.8.1
@nrwl/nx-cloud : undefined
@nrwl/react : undefined
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/storybook : 13.8.1
@nrwl/tao : 13.8.1
@nrwl/web : 13.8.1
@nrwl/workspace : 13.8.1
typescript : 4.5.5
rxjs : 7.5.4
---------------------------------------
Community plugins:
@angular/animations: 13.2.2
@angular/cdk: 13.2.2
@angular/common: 13.2.2
@angular/compiler: 13.2.2
@angular/core: 13.2.2
@angular/forms: 13.2.2
@angular/material: 13.2.2
@angular/platform-browser: 13.2.2
@angular/platform-browser-dynamic: 13.2.2
@angular/router: 13.2.2
@auth0/auth0-angular: 1.7.0
@ngneat/edit-in-place: 1.6.1
@ngneat/transloco: 3.1.3
@ngrx/component: 13.0.2
@ngrx/component-store: 13.0.2
ng2-charts: 3.0.8
single-spa-angular: 6.0.1
@angular-builders/custom-webpack: 13.1.0
@angular-devkit/architect: 0.1302.3
@angular-devkit/build-angular: 13.2.3
@angular/cli: 13.2.3
@angular/compiler-cli: 13.2.2
@angular/language-service: 13.2.2
@compodoc/compodoc: 1.1.18
@ngneat/spectator: 10.0.0
@storybook/angular: 6.4.19
@twittwer/compodoc: 1.6.6
About this issue
- Original URL
- State: closed
- Created 2 years ago
- Comments: 30 (19 by maintainers)
Hi, I am having the same issue, but not with yarn but with npm. I have checked the package-lock.json where I find the “@swc/core-linux-x64-gnu” as an “optionalDependency” in “node_modules/@swc/core” and “node_modules/@nrwl/eslint-plugin-nx” and and as “requires” in “@nrwl/eslint-plugin-nx” and “@swc/core”. I am using the
npm cicommand which takes care of not caching the node_modules folder. Thus neither one could really be the problem. Any ideas or recommendations?@JosefBredereck I have just checked the windows and everything works as expected. If you have an issue, please follow the following steps:
rm -rf node_modules package-lock.json yarn.lock pnpm-lock.yaml)npm cache cleanoryarn cache clean)npm ioryarnorpnpm)That should ensure your lock file has properly picked up missing
@swc/core-...packages.The same solution applies also to @bubblegumsoldier.
Perhaps you should consider updating to node v16. Not sure if that’s the issue. Either way, the lint passed with the new lock file.
Btw, your CI was running
npm iinstead ofnpm ciso it was overriding the lock file every time.One possible scenario is that the 32-bit version of Node.js is installed and the 64-bit version of VSCode is installed. That is why
@swc\core-wind32-ia32-msvcinstalled buteslint vscode pluginwant to load@swc\core-wind32-x64-msvcHi @jogelin, thank you for reporting the issue.
You should definitely not install
@swc/core-linux-x64-gnuon CI during your pipeline. It should already be set in your lock file as an optional dependency. Can you please check for it in thepackage-lock.jsonoryarn.lock? If not there, you might need to delete the node_modules and your lock file and run install (npm installoryarn) to regenerate them again. All the@swc/core-linux-*should be added as an optional dependency, so your CI machine would pick them up on the install phase. Please have in mind that if you cachenode_moduleson CI, you would have to invalidate the CI cache as well.Let me know if this helped.
Same goes for Win10 with
@swc/core-win32-x64-msvcWhat I was able to discover until now is that the machine was not able to unlink a file during the installation process and caused the required files not to have been added.