Open
Description
Current Behavior
The are two problems with libs...
- Not works inside workspace's next applications, this is described here: Problems with Next and internal libs #30714
- The second and most important issue IMO, occurs when you publish the library to the npm registry and tries to use it inside a next app, no matter if is in a new workspace or a next app created with
create-next-app
command, It just doesn't work.
This issue is to track the second one, but in both cases the issue is the same, the module can't be resolved

Expected Behavior
Packages just should works as expected
GitHub Repo
https://github.com/gperdomor/nx-next-issue
Steps to Reproduce
- Create an empty workspace
- Create a publishable library and publish to npm registry or verdaccio local registry
- Create a Next app using
npc create-next-app
command - Install your published library
- Use the library in a page of your next app
- Run the next app
Nx Report
report
NX Report complete - copy this into the issue template
Node : 22.15.1
OS : darwin-x64
Native Target : x86_64-macos
pnpm : 10.11.0
nx (global) : 21.1.2
nx : 21.1.2
@nx/js : 21.1.2
@nx/eslint : 21.1.2
@nx/eslint-plugin : 21.1.2
@nx/next : 21.1.2
@nx/vite : 21.1.2
@nx/web : 21.1.2
typescript : 5.7.3
---------------------------------------
Registered Plugins:
@nx/js/typescript
@nx/vite/plugin
@nx/eslint/plugin
@nx/next/plugin
---------------------------------------
Cache Usage: 0.00 B / 93.15 GB
Failure Logs
Package Manager Version
pnpm 10.11.0
Operating System
- macOS
- Linux
- Windows
- Other (Please specify)
Additional Information
The issue described in point 2, seems to be related with development
property in package.json exports
fields
"exports": {
"./package.json": "./package.json",
".": {
"development": "./src/index.ts", <------- THIS
"types": "./dist/index.d.ts",
"import": "./dist/index.js",
"default": "./dist/index.js"
}
},
If you install the lib from npm registry and open the node_modules folder, go to the package folder and removes that line from the package.json, and runs your app, then the app works without issues
For testing purposes I published this sample @gperdomor/sample-lib package from the above GitHub repo