"generatePackageJson" does not include dependencies from `libs/*`
See original GitHub issueCurrent Behavior
I’m trying to create a production Nest.js build with a minimal dependency tree. “generatePackageJson” does not include dependencies from a library within my own workspace.
Scenario:
apps/graphql imports libs/config. libs/config imports dotenv (3rd party). dotenv is not included in the package.json of apps/graphql generated file.
Expected Behavior
I expect dotenv to be listed in package.json.
Steps to Reproduce
- Create nest.js app
- Create
confignest.js Library withimport { config } from 'dotenv'; - Import
configlibrary - Add
"generatePackageJson": trueoption to app build target. - Build
- Notice that
dotenvdoes not exist inpackage.json
Failure Logs
Error: Cannot find module 'dotenv'
Environment
> NX Report complete - copy this into the issue template
Node : 16.3.0
OS : darwin x64
npm : 7.15.1
nx : Not Found
@nrwl/angular : Not Found
@nrwl/cli : 12.7.2
@nrwl/cypress : Not Found
@nrwl/devkit : 12.7.2
@nrwl/eslint-plugin-nx : 12.7.2
@nrwl/express : Not Found
@nrwl/jest : 12.7.2
@nrwl/linter : 12.7.2
@nrwl/nest : 12.7.2
@nrwl/next : Not Found
@nrwl/node : 12.7.2
@nrwl/nx-cloud : Not Found
@nrwl/react : Not Found
@nrwl/schematics : Not Found
@nrwl/tao : 12.7.2
@nrwl/web : Not Found
@nrwl/workspace : 12.7.2
@nrwl/storybook : Not Found
@nrwl/gatsby : Not Found
typescript : 4.3.5
Extra Credit
Generated package.json should also either lock to exact package numbers or create a package.lock file. It’s probably easier to just pin down exact package numbers: "some-pkg": "1.2.3" instead of "some-pkg": "^1.2.0"
Issue Analytics
- State:
- Created 2 years ago
- Reactions:12
- Comments:38 (12 by maintainers)
Top Results From Across the Web
Generate package.json on nx build / deployment
This will generate you package.json with the necessary dependencies for your app. Here example: "node-api": { "root": "apps/node ...
Read more >Project Configuration - Nx
You can configure lint rules using these tags to, for instance, ensure that libraries belonging to myteam are not depended on by libraries...
Read more >package.json - npm Docs
This file contains the dependencies renderized and super-streams which can be installed in a new project by executing npm install awesome-web-framework-1.0.0.
Read more >[nrwl/nx] Is it possible to remove all type dependencies in ...
When I build the app (with generatePackageJson set to true ), I noticed that the package is included as a dependency. I'm still...
Read more >Using Nx for React and Typescript Monorepos - Ryosuke
Apparently in v13+ you can add a generatePackageJson flag to the build process. See here on Github. package.json are supported in libraries and ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

I had the exact same problem with the
dotenvpackage missing from the generatedpackage.jsonfile when using the optiongeneratePackageJson.Removing the
dotenvpackage from thedevDependenciespart of the rootpackage.jsonsolved the problem.In case it helps anyone else, my solution to this issue was a bit different.
The build executor is
@nrwl/webpack:webpackfor me and@nrwl/webpackwas missing from my devDeps in package.json. Somehow it was still building to dist/, but without the correct deps.npm i -D @nrwl/webpackfixed things.