As other folks mentioned, npx ships with npm as of 5.0, so you can just npx jest (for example) instead of $(npm bin)/jest or PATH=$(npm bin):$PATH jest.
Setting up your ~/.npmrc can save a lot of time with npm init -y. The interesting keys are the init.foo ones. That section of my npmrc looks like:
The --silent flag for npm run is nice. I have an alias: nr='npm run --silent'.
package-lock.json in 5.0 is the new version of npm-shrinkwrap.json, which is more like yarn.lock (but more deterministic, since it's a snapshot of where modules are on your actual fs). It's also huge and diffs in it are hard to read (and shouldn't be manually edited anyway), so I add package-lock.json -diff to .gitattributes.
npx is also the greatest for non-installed executables. Rather than npm i -g create-react-app every once in a while to keep it up to date, you can just npx create-react-app foo and it'll install CRA temporarily and run it for you. (There's a whole list of things that work great with npxhere, including keeping Node, npm, and npx up to date with npx dist-upgrade).
There's also the super-fast npm ci in npm canary right now, which will save a lot of time on installs in the future.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
As other folks mentioned,
npx
ships with npm as of 5.0, so you can justnpx jest
(for example) instead of$(npm bin)/jest
orPATH=$(npm bin):$PATH jest
.Setting up your ~/.npmrc can save a lot of time with
npm init -y
. The interesting keys are theinit.foo
ones. That section of my npmrc looks like:The
--silent
flag fornpm run
is nice. I have an alias:nr='npm run --silent'
.package-lock.json in 5.0 is the new version of npm-shrinkwrap.json, which is more like yarn.lock (but more deterministic, since it's a snapshot of where modules are on your actual fs). It's also huge and diffs in it are hard to read (and shouldn't be manually edited anyway), so I add
package-lock.json -diff
to.gitattributes
.npx
is also the greatest for non-installed executables. Rather thannpm i -g create-react-app
every once in a while to keep it up to date, you can justnpx create-react-app foo
and it'll install CRA temporarily and run it for you. (There's a whole list of things that work great withnpx
here, including keeping Node, npm, and npx up to date withnpx dist-upgrade
).There's also the super-fast
npm ci
in npm canary right now, which will save a lot of time on installs in the future.