In the latest version of npm, it should list a count of how many packages were installed/added after running npm install (or npm i):

In this case the project I'm working has only a few top-level dependencies and devDependencies listed in the package.json but 281 is actual count of all packages added. I posted a separate question in the hopes of getting more information on the audit count discrepancy.
So I think what I listed above is the simplest approach for getting the count for a specific project. However let's break your question down a little more...
Count for a Project
See above (basically remove your node_modules directory and run npm i).
Count for a Specific Package
The OP's question touches on this with create-react-app. So what if I want to see the total package count for create-react-app?
- Start from a fresh directory.
- Run
npm i create-react-app.
- See the output...

Why create a new directory you ask? Because an existing project might already have some of create-react-apps dependencies installed, thus causing the added count to differ:

Count Global Packages
I don't have a great answer to this one yet (but I'm happy to update the answer if we come across one). Because global installs (npm i -g ...) aren't store in a global package.json, I don't think you can run npm i -g by itself to get the count. It seems one approach might be to do what the OP mentioned, meaning...
- Run
npm ls.
- Copy the output into a text editor and do a line count.
And I'm sure some bash wizard could automate this by piping the output of npm ls to another CLI command or two, e.g. (npm ls | count-lines).
One thing to note here though is that I'm not 100% sure the number of lines is a one-to-one mapping for the number of packages. I seem to recall instances where npm will list a dependency under a package but then put parentheses next to it indicating that it was installed only once (but listed multiple times), is symlinked, etc. So again, not sure of a great solution for globals yet.
UPDATE:
npm ls will list certain dependencies with deduped next to them like so:
[email protected] deduped
So npm ls with a straight line count isn't a perfect approach unless you delete deduped lines and take into account other flags like this one.