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
Table of contents 1. Routing animation 2. Group Q...
Today I helped a classmate solve a problem - Tomc...
Table of contents Preface 1. Configure gzip compr...
Detailed explanation of mysql exists and not exis...
The parameter passed by ${param} will be treated ...
Table of contents 1. Routing Configuration 2. Vue...
We can create jsx/tsx files directly The project ...
This article example shares the specific code of ...
Nginx can use the limit_req_zone directive of the...
Hello everyone, I am Qiufeng. Recently, WeChat ha...
1. Review The Buffer Pool will be initialized aft...
The previous article introduced a detailed exampl...
[ Linux installation of Tomcat8 ] Uninstall Tomca...
【1】<i></i> and <em></em> ...
Effect: Code: <template> <div class=&quo...