question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

"generatePackageJson" does not include dependencies from `libs/*`

See original GitHub issue

Current 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

  1. Create nest.js app
  2. Create config nest.js Library with import { config } from 'dotenv';
  3. Import config library
  4. Add "generatePackageJson": true option to app build target.
  5. Build
  6. Notice that dotenv does not exist in package.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:closed
  • Created 2 years ago
  • Reactions:12
  • Comments:38 (12 by maintainers)

github_iconTop GitHub Comments

5reactions
DeadEye0112commented, Sep 20, 2021

I had the exact same problem with the dotenv package missing from the generated package.json file when using the option generatePackageJson.

Removing the dotenv package from the devDependencies part of the root package.json solved the problem.

4reactions
svaterlauscommented, Oct 5, 2022

In case it helps anyone else, my solution to this issue was a bit different.

The build executor is @nrwl/webpack:webpack for me and @nrwl/webpack was missing from my devDeps in package.json. Somehow it was still building to dist/, but without the correct deps. npm i -D @nrwl/webpack fixed things.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found