@nrwl/js:library — no root entry in project.json causes nx to throw an error
See original GitHub issueCurrent Behavior
Running npx nx generate @nrwl/js:library myTestLib --importPath=@mycompany/myTestLib --publishable --tags=myTestLib to create a non-angular library in an angular workspace causes nx to throw an error.
The generated project.json is missing the { root: "myTestLib" } entry.
Expected Behavior
The @nrwl/js generator scaffolds the json to have a root field containing the lib name.
Steps to Reproduce
Run npx nx generate @nrwl/workspace:workspace-generator test --no-interactive to create a workspace
Run npx nx generate @nrwl/angular:application testapp --tags=mytestapp --no-interactive to create an angular app
Run npx nx generate @nrwl/js:library testlib --tags=testlib --no-interactive to create a new typescript library.
Now try to run nx serve or nx build to see the build failing with:
Failure Logs
node:internal/process/promises:279
triggerUncaughtException(err, true /* fromPromise */);
^
{
stack: "TypeError: Cannot read properties of undefined (reading 'endsWith')\n" +
' at createProjectRootMappings (/Users/**/**/node_modules/@nrwl/workspace/src/core/file-map-utils.js:12:38)\n' +
' at createProjectFileMap (/Users/**/**/node_modules/@nrwl/workspace/src/core/file-map-utils.js:27:33)\n' +
' at /Users/**/Documents/**/node_modules/@nrwl/workspace/src/core/project-graph/daemon/server/project-graph-incremental-recomputation.js:97:65\n' +
' at Generator.next (<anonymous>)\n' +
' at fulfilled (/Users/**/Documents/**/node_modules/tslib/tslib.js:115:62)\n' +
' at processTicksAndRejections (node:internal/process/task_queues:96:5)',
message: "Cannot read properties of undefined (reading 'endsWith')\n" +
'\n' +
'Because of the error the Nx daemon process has exited. The next Nx command is going to restart the daemon process.\n' +
'If the error persists, please run "nx reset".'
}
Environment
Node : 16.15.0
OS : darwin arm64
npm : 8.5.5
nx : 13.9.5
@nrwl/angular : 13.9.5
@nrwl/cypress : 13.9.5
@nrwl/detox : Not Found
@nrwl/devkit : 13.9.5
@nrwl/eslint-plugin-nx : 13.9.5
@nrwl/express : Not Found
@nrwl/jest : 13.9.5
@nrwl/js : 14.1.4
@nrwl/linter : 13.9.5
@nrwl/nest : Not Found
@nrwl/next : Not Found
@nrwl/node : Not Found
@nrwl/nx-cloud : Not Found
@nrwl/nx-plugin : Not Found
@nrwl/react : Not Found
@nrwl/react-native : Not Found
@nrwl/schematics : Not Found
@nrwl/storybook : 13.9.5
@nrwl/web : Not Found
@nrwl/workspace : 13.9.5
typescript : 4.5.5
rxjs : 6.6.7
---------------------------------------
Community plugins:
nx-stylelint: 13.3.0
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:5 (1 by maintainers)

Top Related StackOverflow Question
Hey @oliverkierepka , it may be unrelated, but some of your @nrwl/* packages don’t line up with the version of
nxyou have installed. Aside from@nrwl/nx-cloud, all packages under the nrwl scope should generally be set up with the same version.Can you correct this and check that the issue still reproduces? An easy way to fix this would be to run
nx migrate {v}, wherevis the version of nx you have installed. Alternatively, updating to latest withnx migrate latestwould also work.Nevermind my previous comment. I accidentally commented on the wrong issue. 😄