1

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.

2
  • 2
    Per npm run docs: In addition to the shell's pre-existing PATH, npm run adds node_modules/.bin to the PATH provided to scripts. That's where you'll presumably find pino-pretty. Commented Mar 5, 2022 at 23:53
  • yeah @jarmod. node server.js | node_modules/.bin/pino-pretty also worked. thank you Commented Mar 5, 2022 at 23:57

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.