nx icon indicating copy to clipboard operation
nx copied to clipboard

NX Unable to Find Packages in Packages.json

Open Ryanaldo34 opened this issue 10 months ago • 6 comments

Current Behavior

I get the warning message after running npx nx show projects --affected: "The affected projects might have not been identified properly. The package(s) @nx/cypress, @nx/eslint, @nx/eslint-plugin, @nx/js, @nx/vite, @nx/vue, @nx/web, @nx/workspace, @typescript-eslint/eslint-plugin, @typescript-eslint/parser, @vitest/coverage-v8, @vitest/ui, eslint, nx, typescript, vitest, highcharts, @cypress/code-coverage, @nx/storybook, @storybook/addon-essentials, @storybook/addon-interactions, @storybook/core-server, @storybook/jest, @storybook/test-runner, @storybook/testing-library, @storybook/vue3, @storybook/vue3-vite, allure-commandline, allure-mocha, storybook, ts-node, vite-plugin-dts were not found. Please open an issue in GitHub including the package.json file."

Expected Behavior

It is able to recognize and print the affected projects without any warnings or errors.

GitHub Repo

No response

Steps to Reproduce

  1. run npm install in the repo directory
  2. run npx nx show projects --affected
  3. it prints the list of projects but shows the warning I posted earlier included with the projects

Nx Report

NX   Report complete - copy this into the issue template

Node   : 18.16.1
OS     : win32-x64
npm    : 9.5.1

nx                 : 18.2.2
@nx/js             : 18.2.2
@nx/linter         : 18.2.2
@nx/eslint         : 18.2.2
@nx/workspace      : 18.2.2
@nx/cypress        : 18.2.2
@nx/devkit         : 18.2.2
@nx/eslint-plugin  : 18.2.2
@nx/storybook      : 18.2.2
@nrwl/tao          : 18.2.2
@nx/vite           : 18.2.2
@nx/vue            : 18.2.2
@nx/web            : 18.2.2
typescript         : 5.4.3

Failure Logs

No response

Package Manager Version

npm 9.5.1

Operating System

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

Additional Information

This is a private repository and project so unable to provide a direct link to the repo. Here is the package.json for the monorepo of Vue.JS projects and libraries. package.json

Ryanaldo34 avatar Apr 03 '24 20:04 Ryanaldo34

Is your package-lock.json perhaps not committed?

FrozenPandaz avatar Apr 05 '24 19:04 FrozenPandaz

I'm having the same issue. I don't think package-lock.json is the problem. It happens locally under a fresh install, but it causes no problems locally. In the azure pipeline though it breaks the CI as it's an error not a warning.

Any ideas on what the causes can be? All the libraries it says are missing are present in the package.json and installed.

For me it's the following:

The affected projects might have not been identified properly. The package(s) @azure/msal-browser, @livechat/widget-angular, @livechat/widget-core, @microsoft/applicationinsights-web were not found. Please open an issue in GitHub including the package.json file.

md-idea avatar Apr 08 '24 14:04 md-idea

It seems like @FrozenPandaz you are correct - package-lock.json not being committed to the git repo causes this.

What's the reason it's required out of interest?

md-idea avatar Apr 09 '24 08:04 md-idea

@FrozenPandaz I found that the package-lock.json wasn't committed. I committed and seemed to fix the issue. Do you know of a way to avoid having to commit the package-lock.json? Same thing happens if I add the package-lock.json in the .nxignore file as well

Ryanaldo34 avatar Apr 17 '24 20:04 Ryanaldo34

We are using pnpm hence only pnpm-lock.yml is exists. How then package-lock.json will be generated which seems a requirement? 🤔

Thanks for any suggestion how to solve it if pnpm is preferred.

attilacsanyi avatar Apr 19 '24 08:04 attilacsanyi

This issue has been automatically marked as stale because it hasn't had any recent activity. It will be closed in 14 days if no further activity occurs. If we missed this issue please reply to keep it active. Thanks for being a part of the Nx community! 🙏

github-actions[bot] avatar May 04 '24 00:05 github-actions[bot]

Same as @attilacsanyi , we use PNPM and that uses pnpm-lock.yml rather than package-lock.json

gcko avatar May 08 '24 12:05 gcko

@FrozenPandaz I do believe this issue is not blocked, as it looks to be related to using package managers that do not make use of the package-lock.json file. CC @AgentEnder

Also, 20956 is co-related to this issue

gcko avatar May 10 '24 02:05 gcko

For pnpm, please make sure that pnpm-lock.yaml is committed. You don't need package-lock.json. Nx analyzes package manager lock files to create external nodes in the project graph for npm dependencies.

For yarn, it would be yarn.lock.

Rationale: By default, Nx will also only analyze files which are committed to git. If you really would not like to commit your lockfile, please add !package-lock.json to your .nxignore to un-ignore the git-ignored lockfile from Nx.

FrozenPandaz avatar May 13 '24 18:05 FrozenPandaz

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

github-actions[bot] avatar Jun 14 '24 00:06 github-actions[bot]