nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
23.51k stars 2.34k forks source link

Failed to load plugin '@nrwl/nx': Cannot find module '@swc/core-linux-x64-gnu' #9395

Closed ChazUK closed 2 years ago

ChazUK commented 2 years ago

I'm having an issue running my linting tasks on my CI server. The error message that comes up is that the module can't be found for @swc/core. Is it possible to find out exactly what version it's trying to install? Or is this a problem with eslint 8?

> nx run eds-base:lint

Linting "eds-base"...
Failed to load plugin '@nrwl/nx' declared in 'libs/eds-base/.eslintrc.json » ../../.eslintrc.json#overrides[1]': Cannot find module '@swc/core-linux-x64-gnu'
Require stack:
- /opt/vgi/bamboo/agents/awsagent-1/xml-data/build-dir/ICSCPS-EDS163-LIBEDSBASELINTUNITTEST/node_modules/@swc/core/binding.js
- /opt/vgi/bamboo/agents/awsagent-1/xml-data/build-dir/ICSCPS-EDS163-LIBEDSBASELINTUNITTEST/node_modules/@swc/core/index.js
- /opt/vgi/bamboo/agents/awsagent-1/xml-data/build-dir/ICSCPS-EDS163-LIBEDSBASELINTUNITTEST/node_modules/@swc-node/core/lib/index.js
- /opt/vgi/bamboo/agents/awsagent-1/xml-data/build-dir/ICSCPS-EDS163-LIBEDSBASELINTUNITTEST/node_modules/@swc-node/register/lib/register.js
- /opt/vgi/bamboo/agents/awsagent-1/xml-data/build-dir/ICSCPS-EDS163-LIBEDSBASELINTUNITTEST/node_modules/@nrwl/eslint-plugin-nx/node_modules/nx/src/utils/register.js
- /opt/vgi/bamboo/agents/awsagent-1/xml-data/build-dir/ICSCPS-EDS163-LIBEDSBASELINTUNITTEST/node_modules/@nrwl/eslint-plugin-nx/src/resolve-workspace-rules.js
- /opt/vgi/bamboo/agents/awsagent-1/xml-data/build-dir/ICSCPS-EDS163-LIBEDSBASELINTUNITTEST/node_modules/@nrwl/eslint-plugin-nx/src/index.js
- /opt/vgi/bamboo/agents/awsagent-1/xml-data/build-dir/ICSCPS-EDS163-LIBEDSBASELINTUNITTEST/node_modules/@eslint/eslintrc/dist/eslintrc.cjs
Referenced from: /opt/vgi/bamboo/agents/awsagent-1/xml-data/build-dir/ICSCPS-EDS163-LIBEDSBASELINTUNITTEST/.eslintrc.json

npm list --depth=0 here https://gist.github.com/ChazUK/2cda2da98ae9b3092357aae6b96671c1

and Nx Report is also below

Node : 14.18.2
OS   : linux x64
npm  : 6.14.15

nx : 13.9.2
@nrwl/angular : 13.9.2
@nrwl/cypress : 13.9.2
@nrwl/detox : undefined
@nrwl/devkit : 13.8.1
@nrwl/eslint-plugin-nx : 13.9.2
@nrwl/express : undefined
@nrwl/jest : 13.9.2
@nrwl/js : 13.9.2
@nrwl/linter : 13.9.2
@nrwl/nest : undefined
@nrwl/next : undefined
@nrwl/node : undefined
@nrwl/nx-cloud : undefined
@nrwl/nx-plugin : undefined
@nrwl/react : undefined
@nrwl/react-native : undefined
@nrwl/schematics : undefined
@nrwl/storybook : 13.9.2
@nrwl/web : undefined
@nrwl/workspace : 13.9.2
typescript : 4.5.5
rxjs : 6.6.7
---------------------------------------
Community plugins:
     @compodoc/compodoc: 1.1.18
     @jscutlery/semver: 2.18.1
     @storybook/angular: 6.4.17
     ng-mocks: 13.0.2
     nx-stylelint: 12.3.1
webpro commented 2 years ago

We've had this issue multiple times as well. Using next@canary was the main trick to overcome this. Also re-generating the package-lock.json might help.

yinonov commented 2 years ago

We've had this issue multiple times as well. Using next@canary was the main trick to overcome this. Also re-generating the package-lock.json might help.

Thanks @webpro. that kind of raises other issues but it's a lead...

sampullman commented 2 years ago

We're trying to upgrade to node 16 and see this exact error in Github Actions, and unfortunately regenerating package-lock.json doesn't help. The identical repo works fine under node 14.

sampullman commented 2 years ago

We resolved this by explicitly adding the @swc/core package to our devDependencies

meeroslav commented 2 years ago

This is a duplicate of https://github.com/nrwl/nx/issues/8969

Check this comment or this comment for the potential solution.

The core of the problem is in the lock file missing the optional dependencies requested by @swc/core.

Make sure you run npm ci on your CI and do not provide a skip-optional flag.

github-actions[bot] commented 1 year ago

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.