nx icon indicating copy to clipboard operation
nx copied to clipboard

Target project does not exist: npm:[email protected]

Open markabrahams opened this issue 1 year ago • 8 comments

Current Behavior

When I run: npx nx run myproject:serve

I get the error message:

>  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.
   If you run `npm install --package-lock-only` in your output folder it will regenerate the correct pruned lockfile.
   
Original error: Target project does not exist: npm:[email protected]


   Error: Target project does not exist: npm:[email protected]
    at validateCommonDependencyRules (/home/mark/myproject/node_modules/nx/src/project-graph/project-graph-builder.js:323:15)
    at validateDependency (/home/mark/myproject/node_modules/nx/src/project-graph/project-graph-builder.js:313:5)
    at ProjectGraphBuilder.addDependency (/home/mark/myproject/node_modules/nx/src/project-graph/project-graph-builder.js:190:9)
    at ProjectGraphBuilder.addStaticDependency (/home/mark/myproject/node_modules/nx/src/project-graph/project-graph-builder.js:89:14)
    at /home/mark/myproject/node_modules/nx/src/plugins/js/lock-file/project-graph-pruning.js:81:17
    at Array.forEach (<anonymous>)
    at traverseNode (/home/mark/myproject/node_modules/nx/src/plugins/js/lock-file/project-graph-pruning.js:78:36)
    at /home/mark/myproject/node_modules/nx/src/plugins/js/lock-file/project-graph-pruning.js:80:9
    at Array.forEach (<anonymous>)
    at traverseNode (/home/mark/myproject/node_modules/nx/src/plugins/js/lock-file/project-graph-pruning.js:78:36)

So I'm opening this as per the above request in the error message.

Note that this doesn't occur on the initial compile, but does occur on every recompile after that.

Also note that this doesn't seem to have any impact on the actual serving of the app, which seems fine.

Expected Behavior

No reported error message.

GitHub Repo

No response

Steps to Reproduce

  1. Run command:

npx nx run myproject:serve

  1. Edit a file and save. On recompile the error is produced.

Nx Report

mark@hope:~/myproject$ npx nx report
>  NX  Falling back to ts-node for local typescript execution. This may be a little slower.
  - To fix this, ensure @swc-node/register and @swc/core have been installed

 >  NX   Report complete - copy this into the issue template

   Node   : 18.17.1
   OS     : linux-x64
   npm    : 9.6.7
   
   nx                 : 17.1.3
   @nx/js             : 17.1.3
   @nx/jest           : 17.1.3
   @nx/linter         : 17.1.3
   @nx/eslint         : 17.1.3
   @nx/workspace      : 17.1.3
   @nx/devkit         : 17.1.3
   @nx/esbuild        : 17.1.3
   @nx/eslint-plugin  : 17.1.3
   @nx/node           : 17.1.3
   @nrwl/tao          : 17.1.3
   @nx/webpack        : 17.1.3
   typescript         : 5.2.2

Failure Logs

No response

Package Manager Version

No response

Operating System

  • [ ] macOS
  • [X] Linux
  • [ ] Windows
  • [ ] Other (Please specify)

Additional Information

I haven't yet attempted a repo reproduction due to lack of time at this point, but can try this at some point.

Note that this repo has gone through several upgrades to Nx, so it could be that some artefacts from previous versions causing problems?

Here's the project.json file for the "myproject" app:

{
    "name": "myproject",
    "$schema": "../../node_modules/nx/schemas/project-schema.json",
    "sourceRoot": "apps/myproject/src",
    "projectType": "application",
    "targets": {
        "build": {
            "executor": "@nx/webpack:webpack",
            "outputs": ["{options.outputPath}"],
            "options": {
                "target": "node",
                "compiler": "tsc",
                "outputPath": "dist/apps/myproject",
                "main": "apps/myproject/src/main.ts",
                "tsConfig": "apps/myproject/tsconfig.app.json",
                "assets": ["apps/myproject/src/assets"],
                "generatePackageJson": true
            },
            "configurations": {
                "production": {
                    "optimization": true,
                    "extractLicenses": true,
                    "inspect": false,
                    "fileReplacements": [
                        {
                            "replace": "apps/myproject/src/environments/environment.ts",
                            "with": "apps/myproject/src/environments/environment.prod.ts"
                        }
                    ]
                }
            }
        },
        "serve": {
            "executor": "@nx/js:node",
            "options": {
                "buildTarget": "myproject:build",
                "port": 9239
            },
            "configurations": {
                "production": {
                    "buildTarget": "myproject:build:production"
                }
            }
        },
        "lint": {
            "executor": "@nx/eslint:lint",
            "outputs": ["{options.outputFile}"],
            "options": {
                "lintFilePatterns": ["apps/myproject/**/*.ts"]
            }
        },
        "test": {
            "executor": "@nx/jest:jest",
            "outputs": ["{workspaceRoot}/coverage/{projectRoot}"],
            "options": {
                "jestConfig": "apps/myproject/jest.config.ts"
            }
        }
    },
    "tags": []
}

markabrahams avatar Nov 26 '23 07:11 markabrahams