Visual Studio 2022 npm package manager

Simone Trezzi 1 Reputation point
2022-03-08T11:42:38.513+00:00

Hi, I have this situation in node.js projects in Visual Studio 2022.
My npm package manager shows all packages regardless of their state, as shown in the picture
181024-capture2.png
I would like to see only the packages listed in package.json file. Is there a way to do that?

Thank you.

Best regards,
Simone

Developer technologies Visual Studio Other
0 comments No comments
{count} votes

4 answers

Sort by: Most helpful
  1. Tianyu Sun-MSFT 34,436 Reputation points Microsoft External Staff
    2022-03-09T04:53:14.957+00:00

    Hi @Simone Trezzi ,

    Welcome to Microsoft Q&A forum.

    I don’t find a way to meet your requirement. Both Installed and listed in package.json package and Installed, but not explicitly listed in package.json package will show. And I’m afraid, they will only be sorted and displayed alphabetically, and cannot be grouped or hidden automatically.

    Perhaps you can submit a feature suggestion ticket here: Developer Community.

    Best Regards,
    Tianyu

    • If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
    0 comments No comments

  2. Simone Trezzi 1 Reputation point
    2022-03-09T08:29:18.277+00:00

    Hi, thank you for your answer.
    The thing I don't understand about this "issue" is the fact that in other projects I don't see those "Installed, but not explicitly listed in package.json" npm packages.
    Here's an example of a project in Visual Studio 2019:
    181350-capture-1.png

    Also I had a situation, with VS 2019, where some people were seeing those npm packages and other people not, and the project was the same.

    Best regards,
    Simone


  3. Simone Trezzi 1 Reputation point
    2022-03-09T09:50:42.217+00:00

    Here you can see an extract of the node_modules folder's content (the complete list is way too long...):

    181360-capture-2.png

    181403-capture2-1.png

    You can also see the dependencies written in package.json file:

    181443-capture3.png

    It almost seems that in VS2022, the npm node shows all the sub-dependencies of all the packages.

    Thank you, regards.
    Simone


  4. Simone Trezzi 1 Reputation point
    2022-04-05T13:25:05.663+00:00

    Hi!

    I found out that the "problem" is that nodejstools (Visual Studio npm package manager) uses the '_requiredBy' tag written in "package.json" files inside the dependencies folders in node_modules.
    Newer versions of node.js/npm have deprecated all tags that start with '_' in package.json files, so nodejstools can't correctly render the dependencies tree.
    A work around seems to be possible by manually writing that tag in the files.

    Best regards,
    Simone


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.