Skip to content

nx affected throws error when installing npm: prefixed package versions #13228

@mattlewis92

Description

@mattlewis92

Current Behavior

Adding a new package that is a forked version of the original using this syntax:

"eslint-plugin-disable-autofix": "npm:@mattlewis92/[email protected]",

Throws an error when running affected via pnpm nx affected:test

TypeError: Cannot read properties of undefined (reading 'name')
    at getTouchedNpmPackages (/Users/mattlewis/Code/clickup/frontend/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/affected/locators/npm-packages.js:24:41)
    at /Users/mattlewis/Code/clickup/frontend/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/affected/affected-project-graph.js:31:27
    at Array.reduce (<anonymous>)
    at filterAffected (/Users/mattlewis/Code/clickup/frontend/node_modules/.pnpm/[email protected]/node_modules/nx/src/project-graph/affected/affected-project-graph.js:30:52)
    at projectsToRun (/Users/mattlewis/Code/clickup/frontend/node_modules/.pnpm/[email protected]/node_modules/nx/src/command-line/affected.js:100:55)
    at Object.<anonymous> (/Users/mattlewis/Code/clickup/frontend/node_modules/.pnpm/[email protected]/node_modules/nx/src/command-line/affected.js:29:26)
    at Generator.next (<anonymous>)
    at fulfilled (/Users/mattlewis/Code/clickup/frontend/node_modules/.pnpm/[email protected]/node_modules/tslib/tslib.js:115:62)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)

It seems the error is thrown here as npmPackage is undefined (one side of the comparison is using eslint-plugin-disable-autofix as the package name and the other is using @mattlewis92/eslint-plugin-disable-autofix):

https://github.com/nrwl/nx/blob/master/packages/nx/src/project-graph/affected/locators/npm-packages.ts#L31-L33

Expected Behavior

Affected doesn't throw an error

Steps to Reproduce

See nrwl/nx-examples#244

https://app.circleci.com/pipelines/github/nrwl/nx-examples/436/workflows/d81d036c-2fd9-400e-a6ef-a1db34e8f499/jobs/2493

Failure Logs

See above

Environment

 >  NX   Report complete - copy this into the issue template

   Node : 16.17.1
   OS   : darwin arm64
   pnpm : 7.9.0
   
   nx : 15.1.1
   @nrwl/angular : 15.1.1
   @nrwl/cypress : 15.1.1
   @nrwl/detox : Not Found
   @nrwl/devkit : 15.1.1
   @nrwl/esbuild : Not Found
   @nrwl/eslint-plugin-nx : 15.1.1
   @nrwl/expo : Not Found
   @nrwl/express : Not Found
   @nrwl/jest : 15.1.1
   @nrwl/js : 15.1.1
   @nrwl/linter : 15.1.1
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : 15.1.1
   @nrwl/nx-cloud : 15.0.2
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 15.1.1
   @nrwl/react-native : Not Found
   @nrwl/rollup : 15.1.1
   @nrwl/schematics : Not Found
   @nrwl/storybook : 15.1.1
   @nrwl/web : 15.1.1
   @nrwl/webpack : 15.1.1
   @nrwl/workspace : 15.1.1
   typescript : 4.8.4
   ---------------------------------------
   Local workspace plugins:
   ---------------------------------------
   Community plugins:
         @fortawesome/angular-fontawesome: 0.10.1
         @ngrx/effects: 14.0.2
         @ngrx/entity: 14.0.2
         @ngrx/router-store: 14.0.2
         @ngrx/schematics: 14.0.2
         @ngrx/store: 14.0.2
         @ngrx/store-devtools: 14.0.2
         @rx-angular/cdk: 1.0.0-rc.2
         @rx-angular/state: 1.6.1
         @rx-angular/template: 1.0.0-rc.3
         angular-calendar: 0.30.1
         ngx-bootstrap: 3.2.0
         @compodoc/compodoc: 1.1.18
         @jscutlery/semver: 2.25.2
         @ngneat/spectator: 12.0.1
         @storybook/angular: 6.5.10
         eslint-plugin-ngrx: 2.1.0
         ng-mocks: 14.3.2
         ngx-deploy-npm: 4.0.0

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions