• Guest
HabraHabr
  • Main
  • Users

  • Development
    • Programming
    • Information Security
    • Website development
    • JavaScript
    • Game development
    • Open source
    • Developed for Android
    • Machine learning
    • Abnormal programming
    • Java
    • Python
    • Development of mobile applications
    • Analysis and design of systems
    • .NET
    • Mathematics
    • Algorithms
    • C#
    • System Programming
    • C++
    • C
    • Go
    • PHP
    • Reverse engineering
    • Assembler
    • Development under Linux
    • Big Data
    • Rust
    • Cryptography
    • Entertaining problems
    • Testing of IT systems
    • Testing Web Services
    • HTML
    • Programming microcontrollers
    • API
    • High performance
    • Developed for iOS
    • CSS
    • Industrial Programming
    • Development under Windows
    • Image processing
    • Compilers
    • FPGA
    • Professional literature
    • OpenStreetMap
    • Google Chrome
    • Data Mining
    • PostgreSQL
    • Development of robotics
    • Visualization of data
    • Angular
    • ReactJS
    • Search technologies
    • Debugging
    • Test mobile applications
    • Browsers
    • Designing and refactoring
    • IT Standards
    • Solidity
    • Node.JS
    • Git
    • LaTeX
    • SQL
    • Haskell
    • Unreal Engine
    • Unity3D
    • Development for the Internet of things
    • Functional Programming
    • Amazon Web Services
    • Google Cloud Platform
    • Development under AR and VR
    • Assembly systems
    • Version control systems
    • Kotlin
    • R
    • CAD/CAM
    • Customer Optimization
    • Development of communication systems
    • Microsoft Azure
    • Perfect code
    • Atlassian
    • Visual Studio
    • NoSQL
    • Yii
    • Mono и Moonlight
    • Parallel Programming
    • Asterisk
    • Yandex API
    • WordPress
    • Sports programming
    • Lua
    • Microsoft SQL Server
    • Payment systems
    • TypeScript
    • Scala
    • Google API
    • Development of data transmission systems
    • XML
    • Regular expressions
    • Development under Tizen
    • Swift
    • MySQL
    • Geoinformation services
    • Global Positioning Systems
    • Qt
    • Dart
    • Django
    • Development for Office 365
    • Erlang/OTP
    • GPGPU
    • Eclipse
    • Maps API
    • Testing games
    • Browser Extensions
    • 1C-Bitrix
    • Development under e-commerce
    • Xamarin
    • Xcode
    • Development under Windows Phone
    • Semantics
    • CMS
    • VueJS
    • GitHub
    • Open data
    • Sphinx
    • Ruby on Rails
    • Ruby
    • Symfony
    • Drupal
    • Messaging Systems
    • CTF
    • SaaS / S+S
    • SharePoint
    • jQuery
    • Puppet
    • Firefox
    • Elm
    • MODX
    • Billing systems
    • Graphical shells
    • Kodobred
    • MongoDB
    • SCADA
    • Hadoop
    • Gradle
    • Clojure
    • F#
    • CoffeeScript
    • Matlab
    • Phalcon
    • Development under Sailfish OS
    • Magento
    • Elixir/Phoenix
    • Microsoft Edge
    • Layout of letters
    • Development for OS X
    • Forth
    • Smalltalk
    • Julia
    • Laravel
    • WebGL
    • Meteor.JS
    • Firebird/Interbase
    • SQLite
    • D
    • Mesh-networks
    • I2P
    • Derby.js
    • Emacs
    • Development under Bada
    • Mercurial
    • UML Design
    • Objective C
    • Fortran
    • Cocoa
    • Cobol
    • Apache Flex
    • Action Script
    • Joomla
    • IIS
    • Twitter API
    • Vkontakte API
    • Facebook API
    • Microsoft Access
    • PDF
    • Prolog
    • GTK+
    • LabVIEW
    • Brainfuck
    • Cubrid
    • Canvas
    • Doctrine ORM
    • Google App Engine
    • Twisted
    • XSLT
    • TDD
    • Small Basic
    • Kohana
    • Development for Java ME
    • LiveStreet
    • MooTools
    • Adobe Flash
    • GreaseMonkey
    • INFOLUST
    • Groovy & Grails
    • Lisp
    • Delphi
    • Zend Framework
    • ExtJS / Sencha Library
    • Internet Explorer
    • CodeIgniter
    • Silverlight
    • Google Web Toolkit
    • CakePHP
    • Safari
    • Opera
    • Microformats
    • Ajax
    • VIM
  • Administration
    • System administration
    • IT Infrastructure
    • *nix
    • Network technologies
    • DevOps
    • Server Administration
    • Cloud computing
    • Configuring Linux
    • Wireless technologies
    • Virtualization
    • Hosting
    • Data storage
    • Decentralized networks
    • Database Administration
    • Data Warehousing
    • Communication standards
    • PowerShell
    • Backup
    • Cisco
    • Nginx
    • Antivirus protection
    • DNS
    • Server Optimization
    • Data recovery
    • Apache
    • Spam and antispam
    • Data Compression
    • SAN
    • IPv6
    • Fidonet
    • IPTV
    • Shells
    • Administering domain names
  • Design
    • Interfaces
    • Web design
    • Working with sound
    • Usability
    • Graphic design
    • Design Games
    • Mobile App Design
    • Working with 3D-graphics
    • Typography
    • Working with video
    • Work with vector graphics
    • Accessibility
    • Prototyping
    • CGI (graphics)
    • Computer Animation
    • Working with icons
  • Control
    • Careers in the IT industry
    • Project management
    • Development Management
    • Personnel Management
    • Product Management
    • Start-up development
    • Managing the community
    • Service Desk
    • GTD
    • IT Terminology
    • Agile
    • Business Models
    • Legislation and IT-business
    • Sales management
    • CRM-systems
    • Product localization
    • ECM / EDS
    • Freelance
    • Venture investments
    • ERP-systems
    • Help Desk Software
    • Media management
    • Patenting
    • E-commerce management
    • Creative Commons
  • Marketing
    • Conferences
    • Promotion of games
    • Internet Marketing
    • Search Engine Optimization
    • Web Analytics
    • Monetize Web services
    • Content marketing
    • Monetization of IT systems
    • Monetize mobile apps
    • Mobile App Analytics
    • Growth Hacking
    • Branding
    • Monetize Games
    • Display ads
    • Contextual advertising
    • Increase Conversion Rate
  • Sundry
    • Reading room
    • Educational process in IT
    • Research and forecasts in IT
    • Finance in IT
    • Hakatonas
    • IT emigration
    • Education abroad
    • Lumber room
    • I'm on my way

A guide to Node.js, Part 5: npm and npx

Today, in the fifth part of the translation of the Node.js manual, we will finish the analysis of the npm capabilities, in particular, we will touch upon such issues as finding the installed versions of npm-packages, installing old versions of packages, updating dependencies, local and global uninstalling packages. Here we will talk about npx.
 
 
A guide to Node.js, Part 5: npm and npx
 
 
[Советуем почитать]Other parts of the [/b] cycle.
Part 1:
General information and getting started

 
Part 2: jаvascript, V? some tricks of development
 
Part 3: Hosting, REPL, work with the console, modules
 
Part 4: npm, package.json and package-lock.json files
 
Part 5: npm and npx
 
npx , which appeared in npm 5.2. One of its features is the launch of executable files that are part of npm-packages. We have already considered using npx to run a similar file from the cowsay package. Now let's talk about this in more detail.
 
 


▍Use npx to simplify the launch of local commands


 
Node.js-developers published a lot of executable files (utilities) in the form of packages that were supposed to be installed globally, which provided convenient access to their capabilities, since they could be launched from the command line simply by typing the name of the corresponding command. However, working in such an environment was very uncomfortable if you had to install different versions of the same packages.
 
 
Application of the command type npx commandname leads to an automatic search for the desired file in the project folder node_modules . This eliminates the need to know the exact path to a similar file. It also makes it unnecessary to install the package globally with access to it from anywhere in the file system by using the system variable PATH .
 
 

▍Using utilities without having to install them


 
In npx there is one more interesting possibility, thanks to which utilities can be launched without their preliminary installation. This is useful mainly for the following reasons:
 
 
  •  
  • No installation of utilities is required.  
  • You can run different versions of the same utilities, indicating the correct version using the design @version .  

 
Let's look at how to use this mechanism, using the example of the utility already known to you. cowsay . So, if the cowsay package is installed globally, execute the command on the command line. cowsay "Hello" will lead to the conclusion in the console of the "talking" cow:
 
 
    _______
< Hello >
-------
^ __ ^
(oo) _______
(__)) /
|| ---- w |
|| ||

 
If the cowsay package is not installed globally, a similar command will generate an error.
 
 
The npx utility allows you to run such commands without installing them. It looks like, within the framework of our example, so:
 
 
    npx cowsay "Hello"    

 
Such a command will work, but although the "talking" cow, by and large, does not bring much benefit, the same approach can be used to perform much more useful commands. Here are some examples:
 
 
  •  
  • There is a command line tool for creating and running Vue applications. With the use of npx it can be called so: npx vue create my-vue-app .  
  • To create React-applications, you can use the utility create-react-app . Its call through npx looks like this: npx create-react-app my-react-app .  

 
After downloading and using the appropriate code, npx will remove it.
 
 

▍Chart jаvascript code using different versions of Node.js


 
In order to run some code using different versions of Node.js, you can, with the use of npx, access the npm-package node , indicating its version. It looks like this:
 
 
    npx node @ 6 -v # v???
npx node @ 8 -v # v???

 
This allows you to abandon the use of tools like nvm or other version managers Node.js.
 
 

▍ Running arbitrary code snippets available at a certain address


 
Npx allows you to run not only the code published in npm. In particular, if you have a link to a piece of code (say, published on GitHub gist), you can run it as
 
 
    npx https://gist.github.com/zkat/4bc19503fe9e9309e2bfaa2c58074d32  
 
Of course, when you run this code, you should not forget about security. Npx gives the developer great opportunities, but they also mean a big responsibility.
 
 


▍ Results


 
Today we talked about some useful npm mechanisms and about using npx. At this stage, you should have a basic understanding of the npm device and the methods of working with this package manager. If you want to learn more deeply npm - refer to page documentation of the project and more experiment.
 
 
Next time, we will discuss some of the basic mechanisms of Node.js, understanding which is necessary for the successful development of applications for this platform.
 
 
Dear readers! Do you use npx?
 
 

It may be interesting

  • Comments
  • About article
  • Similar news
This publication has no comments.

weber

Author

24-09-2018, 12:14

Publication Date

Node.JS / Compilers

Category
  • Comments: 0
  • Views: 532
Comparing NPM vs Yarn speed
node.js serverside - work on the bugs.
Local NPM repository in 5 minutes with
Node.js without node_modules
4 ways to import the package into Go
Release Node.js v10 and NPM 6
Write a comment
Name:*
E-Mail:


Comments

Can I find someone to write my paper for me free? At our cheap for-pay academic help service with writers across all subjects. Discover more about us here.
write a paper online free
Yesterday, 19:45

nushra45

Pretty nice post. I  just stumbled upon your weblog and wanted to say that I have really enjoyed  browsing your blog posts. After all I’ll be subscribing to your feed and I  hope you write again soon!  soaptoday
Yesterday, 17:35

Legend SEO

Awesome blog. I enjoyed reading your articles. This is truly a great read for me. I have bookmarked it and I am looking forward to reading new articles. Keep up the good work!
vitamin tablets
Yesterday, 17:22

taxiseo2

Tvitamin chis is a wonderful article, Given so much info in it, These type of articles keeps the users interest in the website, and keep on sharing more ... good luck.
Yesterday, 17:10

taxiseo2

КОД не работает! у event нет ни obj ни object!!! Напишите нормально! Если писать рабочие примеры, то у людей все будет работать!
Yesterday, 15:40

Бородин Степан

Adv
Website for web developers. New scripts, best ideas, programming tips. How to write a script for you here, we have a lot of information about various programming languages. You are a webmaster or a beginner programmer, it does not matter, useful articles will help to make your favorite business faster.

Login

Registration Forgot password