npx

पैकेज और रनटाइम

इस्तेमाल

npx [-y] <package>[@version] [args...]

किसी package की executable चलाता है, पहले node_modules/.bin देखता है और न मिले तो अस्थायी रूप से उतार लेता है; टाइपिंग की एक ग़लती अनजान package ले आ सकती है, इसलिए --no से इसे स्थानीय तक सीमित रखें।

आम विकल्प

विकल्पअर्थ
-yinstall without asking first
--nofail instead of downloading anything
-p <pkg>make a package available, then run a command from it
-c "<cmd>"run the command through a shell with the bin path set
--package <pkg>the long form of -p

उदाहरण

npx tsc --noEmit

runs the typescript in node_modules, no global install

npx -y create-next-app@latest my-app

fetches a scaffolder for one use and forgets it

npx --no eslint .

uses the local eslint or fails, instead of quietly downloading one

सवाल हमेशा यही है कि क्या कहाँ जाए: इस प्रोजेक्ट के भीतर, या पूरी मशीन पर।

कैसे पढ़ें

  • बड़े कोष्ठक [ ] उस हिस्से को दिखाते हैं जिसे छोड़ा जा सकता है।
  • तीन बिंदु … का मतलब है एक से ज़्यादा दिए जा सकते हैं।
  • विकल्पों में बड़े-छोटे अक्षर मायने रखते हैं — कुछ कमांड में -r और -R अलग काम करते हैं।

आम सवाल

Q. npx क्या करता है?

किसी package की executable चलाता है, पहले node_modules/.bin देखता है और न मिले तो अस्थायी रूप से उतार लेता है; टाइपिंग की एक ग़लती अनजान package ले आ सकती है, इसलिए --no से इसे स्थानीय तक सीमित रखें।

Q. इसे कैसे लिखें?

npx [-y] <package>[@version] [args...] — बड़े कोष्ठक वह हिस्सा दिखाते हैं जो छोड़ा जा सकता है।

Q. कितने विकल्प जानने लायक़ हैं?

यहाँ 5 दिए हैं; पूरी सूची man npx में है। यह कमांड पैकेज और रनटाइम में आती है।

मिलती-जुलती कमांड

man पेज: man npx