Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WASM error when running npx nx build my-app-name --verbose (Error: invalid type: unit value, expected struct Options) #29497

Open
1 of 4 tasks
dave-kooply opened this issue Jan 1, 2025 · 0 comments

Comments

@dave-kooply
Copy link

dave-kooply commented Jan 1, 2025

Current Behavior

Hey,

We started working with NX 2 weeks ago (v20.2.2). Our initial set up was to have one package.json file in the root, meaning libs and apps won't have their own package.json file, it will be generated for them in build time (esbuild: "generatePackageJson": true).
after 3 days of setting all tasks, NX was working seamlessly. All basic tasks was working (tests, lint, build, and more) and deployment to our Kube env was successful. Good job NX.

Yesterday I used 'nx import ...' to add one more app, I added the subset of npm packages needed for the newly added app, ran locally all tasks (tests, lint, build, and more) and all pass with flying green colors.

Once I pushed the changes to Github and the automated deploy workflow reached the "npx nx show projects --affected --type app --verbose" the command printed a warn on usage of an experimental flag:
(node:2498) ExperimentalWarning: WASI is an experimental feature and might change at any time
(Use node --trace-warnings ... to show where the warning was created)
and the command exit with error code 1

For testing purposes I override this step and reached the "npx nx build my-app-name --configuration=production --skip-nx-cache --verbose"
I got the following error:
NX Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it. See errors below.
Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
An error occurred while processing files for the @nx/jest/plugin plugin.
- apps/my-app-name-1/jest.config.ts: invalid type: unit value, expected struct Options
Error: invalid type: unit value, expected struct Options
at module.exports.__wbindgen_error_new (/home/runner/work/backend/backend/node_modules/@swc/wasm/wasm.js:552:17)
at null. (wasm://wasm/053083e6:1:15562816)
at null. (wasm://wasm/053083e6:1:16458264)
at null. (wasm://wasm/053083e6:1:16614049)
at null. (wasm://wasm/053083e6:1:5423603)
at null. (wasm://wasm/053083e6:1:3147300)
at null. (wasm://wasm/053083e6:1:12769742)
at null. (wasm://wasm/053083e6:1:1487331)
at null. (wasm://wasm/053083e6:1:2844031)
at null. (wasm://wasm/053083e6:1:1934231)
- apps/my-app-name-2/jest.config.ts: invalid type: unit value, expected struct Options
Error: invalid type: unit value, expected struct Options
at module.exports.__wbindgen_error_new (/home/runner/work/backend/backend/node_modules/@swc/wasm/wasm.js:552:17)
at null. (wasm://wasm/053083e6:1:15562816)
at null. (wasm://wasm/053083e6:1:16458264)
at null. (wasm://wasm/053083e6:1:16614049)
at null. (wasm://wasm/053083e6:1:5423603)
at null. (wasm://wasm/053083e6:1:3147300)
at null. (wasm://wasm/053083e6:1:12769742)
at null. (wasm://wasm/053083e6:1:1487331)
at null. (wasm://wasm/053083e6:1:2844031)
at null. (wasm://wasm/053083e6:1:1934231)
- libs/my-lib-name-1/jest.config.ts: invalid type: unit value, expected struct Options
Error: invalid type: unit value, expected struct Options
at module.exports.__wbindgen_error_new (/home/runner/work/backend/backend/node_modules/@swc/wasm/wasm.js:552:17)
at null. (wasm://wasm/053083e6:1:15562816)
at null. (wasm://wasm/053083e6:1:16458264)
at null. (wasm://wasm/053083e6:1:16614049)
at null. (wasm://wasm/053083e6:1:5423603)
at null. (wasm://wasm/053083e6:1:3147300)
at null. (wasm://wasm/053083e6:1:12769742)
at null. (wasm://wasm/053083e6:1:1487331)
at null. (wasm://wasm/053083e6:1:2844031)
at null. (wasm://wasm/053083e6:1:1934231)

Please notice that the error repeats 3 times, each per 2 apps and 1 lib. the file "jest.config.ts" is auto generated when you add new app!

FYI 1, one of the first "fixes" I tried was to upgrade NX to v2.3.0, all issue still happen except for the Node warning on the experimental flag disappeared (see above, ExperimentalWarning: WASI....)
FYI 2, I reverted the second app import and all workflow step were back working as expected.

I found an issue that was open here on Mar 20, 2024 (#22407), there is a suggestion in the thread to delete package-lock.json, once I removed the lock file the NX commands started to work again.

BUT.. Since I removed the package-lock file we have a new issue, when the docker image is been built, the auto generated package.json is missing some packages, hence the container won't start due to missing node modules.
When I check the container files, indeed some dependencies of top-dependencies are missing.
To overcome it I docker COPY the root package.json and use it for now (build time is now much higher).

Any suggestions or fix would be appreciated.
Thanks Dave

Expected Behavior

I would expects the NX command to overcome package.lock issues and not break, or at least print better errors.
the "npx nx show projects --affected --type app --verbose" did print node error but exit with code 1 without any error.

GitHub Repo

No response

Steps to Reproduce

  1. Setup NX project with one package.json in the root folder, add one lib (./libs/my-lib-name-1) and one app (./apps/my-app-name-1)
  2. Import one more app to the project, manually add missing NPM packages to the root package.json.
  3. Run 'npx nx show projects --affected --type app --verbose' in a Github action workflow, should exit with code 1
  4. Run 'npx nx build my-app-name-1 --configuration=production --skip-nx-cache --verbose' in a Github action workflow, should exit with code 1 and the long WASM error (see above)

Nx Report

NX   Report complete - copy this into the issue template

Node           : 20.18.1
OS             : linux-x64
Native Target  : x86_64-linux
npm            : 10.8.2

nx                 : 20.3.0
@nx/js             : 20.3.0
@nx/jest           : 20.3.0
@nx/eslint         : 20.3.0
@nx/workspace      : 20.3.0
@nx/devkit         : 20.3.0
@nx/esbuild        : 20.3.0
@nx/eslint-plugin  : 20.3.0
@nx/node           : 20.3.0
typescript         : 5.7.2
---------------------------------------
Registered Plugins:
@nx/eslint/plugin
@nx/jest/plugin

Failure Logs

NX   Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it. See errors below.
Failed to process project graph. Run "nx reset" to fix this. Please report the issue if you keep seeing it.
      An error occurred while processing files for the @nx/jest/plugin plugin.
    - apps/my-app-name-1/jest.config.ts: invalid type: unit value, expected struct Options
      Error: invalid type: unit value, expected struct Options
          at module.exports.__wbindgen_error_new (/home/runner/work/backend/backend/node_modules/@swc/wasm/wasm.js:552:17)
          at null.<anonymous> (wasm://wasm/053083e6:1:15562816)
          at null.<anonymous> (wasm://wasm/053083e6:1:16458264)
          at null.<anonymous> (wasm://wasm/053083e6:1:16614049)
          at null.<anonymous> (wasm://wasm/053083e6:1:542[36](https://github.com/company-name/backend/actions/runs/12560794501/job/35018669548#step:19:37)03)
          at null.<anonymous> (wasm://wasm/053083e6:1:3147300)
          at null.<anonymous> (wasm://wasm/053083e6:1:12769742)
          at null.<anonymous> (wasm://wasm/053083e6:1:1487331)
          at null.<anonymous> (wasm://wasm/053083e6:1:2844031)
          at null.<anonymous> (wasm://wasm/053083e6:1:1934231)
    - apps/my-app-name-2/jest.config.ts: invalid type: unit value, expected struct Options
      Error: invalid type: unit value, expected struct Options
          at module.exports.__wbindgen_error_new (/home/runner/work/backend/backend/node_modules/@swc/wasm/wasm.js:552:17)
          at null.<anonymous> (wasm://wasm/053083e6:1:15562816)
          at null.<anonymous> (wasm://wasm/053083e6:1:16458264)
          at null.<anonymous> (wasm://wasm/053083e6:1:1661[40](https://github.com/company-name/backend/actions/runs/12560794501/job/35018669548#step:19:41)49)
          at null.<anonymous> (wasm://wasm/053083e6:1:5423603)
          at null.<anonymous> (wasm://wasm/053083e6:1:3147300)
          at null.<anonymous> (wasm://wasm/053083e6:1:127697[42](https://github.com/company-name/backend/actions/runs/12560794501/job/35018669548#step:19:43))
          at null.<anonymous> (wasm://wasm/053083e6:1:1487331)
          at null.<anonymous> (wasm://wasm/053083e6:1:28[44](https://github.com/company-name/backend/actions/runs/12560794501/job/35018669548#step:19:45)031)
          at null.<anonymous> (wasm://wasm/053083e6:1:1934231)
    - libs/my-lib-name-1/jest.config.ts: invalid type: unit value, expected struct Options
      Error: invalid type: unit value, expected struct Options
          at module.exports.__wbindgen_error_new (/home/runner/work/backend/backend/node_modules/@swc/wasm/wasm.js:552:17)
          at null.<anonymous> (wasm://wasm/053083e6:1:15562816)
          at null.<anonymous> (wasm://wasm/053083e6:1:16[45](https://github.com/company-name/backend/actions/runs/12560794501/job/35018669548#step:19:46)8264)
          at null.<anonymous> (wasm://wasm/053083e6:1:16614049)
          at null.<anonymous> (wasm://wasm/053083e6:1:5423603)
          at null.<anonymous> (wasm://wasm/053083e6:1:31[47](https://github.com/company-name/backend/actions/runs/12560794501/job/35018669548#step:19:48)300)
          at null.<anonymous> (wasm://wasm/053083e6:1:12769742)
          at null.<anonymous> (wasm://wasm/053083e6:1:1[48](https://github.com/company-name/backend/actions/runs/12560794501/job/35018669548#step:19:49)7331)
          at null.<anonymous> (wasm://wasm/053083e6:1:2844031)
          at null.<anonymous> (wasm://wasm/053083e6:1:1934231)

Package Manager Version

10.8.2

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

I have a list of NPM package that I add to the root package.json, to support the second app, maybe one of the dependencies can cause it:
"@googleapis/androidpublisher": "^8.4.0",
"@kubernetes/client-node": "^0.21.0",
"ascii-table3": "^0.9.0",
"csv-parser": "^3.0.0",
"firebase-cli": "^1.2.0",
"firebase-tools": "^11.20.0",
"jszip": "^3.10.1",
"loose-json": "^1.1.2",
"mustache": "^4.2.0",
"octokit": "^2.0.10",
"passport": "^0.6.0",
"passport-google-oauth2": "^0.2.0",
"passport-jwt": "^4.0.1",
"typescript-json-schema": "^0.55.0",
"vite-express": "^0.9.2",
"yaml": "^2.3.1",
"zod": "^3.23.8"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant