nrwl / nx

Smart Monorepos · Fast CI
https://nx.dev
MIT License
22.72k stars 2.27k forks source link

Cannot generate pruned lock file #21049

Open theTechGoose opened 6 months ago

theTechGoose commented 6 months ago

Current Behavior

When building a nestjs project with NX in monorepo, it shoots an annoying error where it cant find an npm package. This has already been described in #15835 however this issue still occurs.

Expected Behavior

I'd like the console to not reflect the error

GitHub Repo

Its private because contains my companies IP

Steps to Reproduce

1.Make an NX project

  1. Make a Nest project
  2. NX serve --watch
  3. make a change in the project
  4. save

Nx Report

nx                 : 17.2.7
   @nx/js             : 17.2.7
   @nx/jest           : 17.2.7
   @nx/linter         : 17.2.7
   @nx/eslint         : 17.2.7
   @nx/workspace      : 17.2.7
   @nx/devkit         : 17.2.7
   @nx/esbuild        : 17.2.7
   @nx/eslint-plugin  : 17.2.7
   @nx/nest           : 17.2.7
   @nx/node           : 17.2.7
   @nrwl/tao          : 17.2.7
   @nx/webpack        : 17.2.7
   typescript         : 5.2.2

Failure Logs

NX   An error occured while creating pruned lockfile
   Please open an issue at `https://github.com/nrwl/nx/issues/new?template=1-bug.yml` and provide a reproduction.
   To prevent the build from breaking we are returning the root lock file.

Original error: Target project does not exist: npm:tmp@0.0.33
   Error: Target project does not exist: npm:tmp@0.0.33
    at validateCommonDependencyRules (/Users/goose/Documents/programming/ai-monsters/node_modules/nx/src/project-graph/project-graph-builder.js:323:15)
    at validateDependency (/Users/goose/Documents/programming/ai-monsters/node_modules/nx/src/project-graph/project-graph-builder.js:313:5)
    at ProjectGraphBuilder.addDependency (/Users/goose/Documents/programming/ai-monsters/node_modules/nx/src/project-graph/project-graph-builder.js:190:9)
    at ProjectGraphBuilder.addStaticDependency (/Users/goose/Documents/programming/ai-monsters/node_modules/nx/src/project-graph/project-graph-builder.js:89:14)
    at /Users/goose/Documents/programming/ai-monsters/node_modules/nx/src/plugins/js/lock-file/project-graph-pruning.js:81:17
    at Array.forEach (<anonymous>)
    at traverseNode (/Users/goose/Documents/programming/ai-monsters/node_modules/nx/src/plugins/js/lock-file/project-graph-pruning.js:78:36)
    at /Users/goose/Documents/programming/ai-monsters/node_modules/nx/src/plugins/js/lock-file/project-graph-pruning.js:80:9
    at Array.forEach (<anonymous>)
    at traverseNode (/Users/goose/Documents/programming/ai-monsters/node_modules/nx/src/plugins/js/lock-file/project-graph-pruning.js:78:36)

Package Manager Version

yarn v1.22.19

Operating System

Additional Information

This issue is not that big of a deal as I have found a workaround; I am using this proxy script so that it does not show the error in the console.

import * as pty from 'node-pty'; import os from 'os';

export async function emaulateServer() { const filters = [ 'An error occured while creating pruned lockfile', 'Target project does not exist: npm:tmp@0.0.33', 'plugins/js/lock-file/project-graph-pruning.js', 'project-graph-builder.js', ];

runProcess('nx build server', '--watch').execScript(...filters); runProcess('firebase emulators:start --only functions,firestore').execScript( ...filters ); }

function runProcess(command: string, ...args: string[]) { return { execScript: (...filters) => { return run(command, filters, args); }, }; }

function run(command: string, filterList: Array, args: string[]) { const shell = os.platform() === 'win32' ? 'powershell.exe' : 'bash';

const child = pty.spawn(shell, [], { name: 'xterm-color', cols: 80, rows: 30, cwd: process.env.PWD, env: process.env, });

child.write(${command} ${args.join(' ')}\r);

child.onData(function (data) { if (!filterList.some((filter) => data.includes(filter))) { process.stdout.write(data); } }); }

jankornfeld commented 5 months ago

getting the same issue just upgraded from nx14 to nx16