npx usage tutorial Tonight, when I was learning Starting from version 5.2, npm added (comes with) the npx command. If it is not installed, please install it manually:
The concept of npm and npx
In summary:
Usage scenarios of npx (some advantages compared to npm)Starting from several usage scenarios, I hope there will be a scenario that corresponds to your current scenario, so that you can apply it directly Use scenario 1: You want to use a package that has already been installed in the project, but you cannot execute it directly (because it is not installed globally, which involves the problem of environment variables) For this scenario, there are some stupid methods:
A more elegant way is to use
Use scenario 2: A package has been installed globally, and a different version of a package has been installed in the project. You want to use the version of the project Taking my pitfall tonight as the second usage scenario, I have already installed the # npm i -g vue-cli@2 has been executed vue -V # [email protected] # cd my-project has already been executed npm i -D @vue/cli@4 vue -V # [email protected] At this time, if you use npx <command corresponding to the package> # Take vue-cli as an example: npx vue create my-project Usage scenario 3: Do not want to install a package globally or in a project, just want to use it temporarily For this scenario, npx create-react-app my-react-project #The react scaffolding will be automatically deleted after the project is built Usage scenario 4: Temporarily use a specific version of the package (not installed locally) As the title suggests, here I suddenly want to use the cd my-vue-project # Enter my vue project npx @vue/cli@3 create big-project # Use the 3.x version of vue-cli to create a project called big-project Some parameters about npx
The most commonly used and important point in this section is point 5. Based on this summary: No matter how many packages and commands are installed (even if only one package is installed), strictly follow This concludes this article about the usage and scenarios of the npx command in Node.js. For more information on the usage of the Node.js npx command, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope you will support 123WORDPRESS.COM in the future! You may also be interested in:
|
<<: How to configure Linux firewall and open ports 80 and 3306
1. Two ways to define react components 1. Functio...
1- Styling dropdown select boxes - Modify the dro...
MySQL DECIMAL data type is used to store exact nu...
The solution to the problem that the PHP7.3 versi...
What is the purpose of this sentence? Copy code Th...
To deploy war with Docker, you must use a contain...
Table of contents Preface know Practice makes per...
illustrate This article was written on 2017-05-20...
After pressing Enter on the webpage, the form is a...
When the img src value is empty, two requests are ...
Table of contents 1. What is grub encryption 2. g...
1 Introduction PostgreSQL is a free software obje...
Preface Share two methods to monitor whether an e...
EXPLAIN shows how MySQL uses indexes to process s...
Drag the mouse to take a screenshot of the page (...