nrwl / nx

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

Error after generating react library in react-standalone example #27683

Open willybeans opened 3 months ago

willybeans commented 3 months ago

Current Behavior

When running the react-standalone application, after generating a library using npx nx g lib mylib --directory=mylib and selecting vite as bundler, the command npm run start fails with the following error: Unable to create nodes for mylib/vite.config.ts using plugin @nx/vite/plugin.. Im not seeing a similar error when i use rollup instead.

Expected Behavior

the application should still be able to run

GitHub Repo

https://github.com/nrwl/nx-recipes/tree/main/react-standalone

Steps to Reproduce

  1. Go to your nx-recipes repo, under react-standalone
  2. npm i
  3. npx nx g lib mylib --directory=mylib
  4. select react lib option
  5. select vite as bundler
  6. select first option (as provided option) for naming
  7. npm run start

Nx Report

me@me-MBP  ~me/test/nx-recipes/react-standalone   main ±  npm run start

> @myreactapp/source@0.0.0 start
> nx serve

 NX   Unable to create nodes for mylib/vite.config.ts using plugin @nx/vite/plugin. 

         Inner Error: Error: Cannot find module 'ajv/dist/core'
Require stack:
- /Users/me/test/nx-recipes/react-standalone/node_modules/ajv-draft-04/dist/index.js
- /Users/me/test/nx-recipes/react-standalone/node_modules/@microsoft/api-extractor/node_modules/@rushstack/node-core-library/lib/JsonSchema.js
- /Users/me/test/nx-recipes/react-standalone/node_modules/@microsoft/api-extractor/node_modules/@rushstack/node-core-library/lib/index.js
- /Users/me/test/nx-recipes/react-standalone/node_modules/@microsoft/api-extractor/lib/api/CompilerState.js
- /Users/me/test/nx-recipes/react-standalone/node_modules/@microsoft/api-extractor/lib/index.js
- /Users/me/test/nx-recipes/react-standalone/node_modules/vite-plugin-dts/dist/index.cjs
- /Users/me/test/nx-recipes/react-standalone/mylib/vite.config.ts
- /Users/me/test/nx-recipes/react-standalone/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:1145:15)
    at Function.Module._load (node:internal/modules/cjs/loader:986:27)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/Users/will/zen/test/nx-recipes/react-standalone/node_modules/ajv-draft-04/src/index.ts:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Object._require.extensions.<computed> [as .js] (file:///Users/will/zen/test/nx-recipes/react-standalone/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:68404:17)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/Users/will/zen/test/nx-recipes/react-standalone/node_modules/@microsoft/api-extractor/node_modules/@rushstack/node-core-library/src/JsonSchema.ts:11:1)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
    at Object._require.extensions.<computed> [as .js] (file:///Users/will/zen/test/nx-recipes/react-standalone/node_modules/vite/dist/node/chunks/dep-9A4-l-43.js:68404:17)
    at Module.load (node:internal/modules/cjs/loader:1208:32)
    at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
    at Module.require (node:internal/modules/cjs/loader:1233:19)
    at require (node:internal/modules/helpers:179:18)
    at Object.<anonymous> (/Users/will/zen/test/nx-recipes/react-standalone/node_modules/@microsoft/api-extractor/node_modules/@rushstack/node-core-library/src/index.ts:66:1)
    at Module._compile (node:internal/modules/cjs/loader:1358:14)

Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.
If the error persists, please run "nx reset".

Failure Logs

No response

Package Manager Version

10.5.2

Operating System

Additional Information

No response

ilchenkoArtem commented 3 months ago

I have the same issue but for vitest

image