What is the difference between running the application using
1)
node server.js
and making a script
"start" : "node server.js"
using
npm run start.
When i type
1)
node server.js | pino-pretty
in terminal there is an error
pino-pretty not found
When i make
"start": "node server.js | pino-pretty"
in package.json and type
npm run start
in terminal it works.
So apparently there is a fundamental difference between running the application in 1 and 2.
CodePudding user response:
The difference is PATH.
Per the npm run docs:
In addition to the shell's pre-existing PATH, npm run adds node_modules/.bin to the PATH provided to scripts.
You'll find pino-pretty in node_modules/.bin
.