Skip to content

TypeScript Project References Bugs #30106

Open
@yuqianma

Description

Current Behavior

repo: https://github.com/yuqianma/nx-bug-presetts

bugs:

  1. Cannot find package 'jsonc-eslint-parser'
  2. Failed to resolve import "@presetts/mainapp-store" from "src/app/app.tsx". Does the file exist?

Expected Behavior

Should import the lib

GitHub Repo

https://github.com/yuqianma/nx-bug-presetts

Steps to Reproduce

all commands ran:

Init the repo

➜  repos pnpx create-nx-workspace --pm pnpm --preset=ts

 NX   Let's create a new workspace [https://nx.dev/getting-started/intro]

✔ Where would you like to create your workspace? · presetts
✔ Would you like to use Prettier for code formatting? · Yes
✔ Which CI provider would you like to use? · skip
✔ Would you like remote caching to make your build faster? · skip

 NX   Creating your v20.4.5 workspace.

✔ Installing dependencies with pnpm
✔ Successfully created the workspace: presetts.
pnpx nx add @nx/react

Add react app

➜  presetts git:(main) pnpx nx g @nx/react:app apps/mainapp 

 NX  Generating @nx/react:application

✔ Which stylesheet format would you like to use? · tailwind
✔ Would you like to add React Router to this application? (y/N) · true
✔ Which bundler do you want to use to build the application? · vite
✔ Which linter would you like to use? · eslint
✔ What unit test runner should be used? · vitest
✔ Which E2E test runner would you like to use? · playwright
UPDATE pnpm-workspace.yaml
...

Add a lib

(by UI)

Executing task: pnpm exec nx generate @nx/js:library --directory=libs/mainapp/store --bundler=vite --importPath=@presetts/mainapp-store --linter=eslint --name=mainapp-store --unitTestRunner=vitest --no-interactive --dry-run

Then modify the app.tsx to import @presetts/mainapp-store

Start the project (tries 1):

➜  presetts git:(main) ✗ pnpx nx serve @presetts/mainapp  

 NX   Failed to process project graph.

An error occurred while processing files for the @nx/eslint/plugin plugin (Defined at nx.json#plugins[2])
.
  - libs/mainapp/store/eslint.config.mjs: Cannot find package 'jsonc-eslint-parser' imported from /home/myq/repos/presetts/libs/mainapp/store/eslint.config.mjs
Did you mean to import "jsonc-eslint-parser/lib/index.js"?

➜  presetts git:(main) ✗ pnpm add -D -w jsonc-eslint-parser

I had to install jsonc-eslint-parser manually as you can see.

Start the project (tries 2):

➜  presetts git:(main) ✗ pnpx nx serve @presetts/mainapp

 NX   The workspace is out of sync

[@nx/js:typescript-sync]: Some TypeScript configuration files are missing project references to the projects they depend on or contain outdated project references.

This will result in an error in CI.

✔ Would you like to sync the identified changes to get your workspace up to date? · yes
✔ The workspace was synced successfully!

Please make sure to commit the changes to your repository.

> nx run @presetts/mainapp:serve

> vite

The CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.

  VITE v5.4.14  ready in 104 ms

  ➜  Local:   http://localhost:4200/
  ➜  press h + enter to show help
Error: The following dependencies are imported but could not be resolved:

  @presetts/mainapp-store (imported by presetts/apps/mainapp/src/app/app.tsx)

Are they installed?

I have no idea why it synced but still could not find the target. Even tried Cursor, not luck.

Nx Report

Node           : 22.13.1
OS             : linux-x64
Native Target  : x86_64-linux
pnpm           : 10.4.1

nx (global)        : 20.4.5
nx                 : 20.4.5
@nx/js             : 20.4.5
@nx/eslint         : 20.4.5
@nx/devkit         : 20.4.5
@nx/eslint-plugin  : 20.4.5
@nx/playwright     : 20.4.5
@nx/react          : 20.4.5
@nx/vite           : 20.4.5
@nx/web            : 20.4.5
typescript         : 5.7.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/vite/plugin
@nx/eslint/plugin
@nx/playwright/plugin

Failure Logs

Package Manager Version

No response

Operating System

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

Additional Information

the system is wsl

Activity

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

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions