How To Install Node Dependencies
npm, pnpm, and Yarn
WebStorm integrates with the npm, Yarn, Yarn 2, and pnpm, so y'all tin can install, locate, update, and remove packages of reusable code from inside the IDE, in the built-in Terminal.
WebStorm too lets you run and debug npm, Yarn, and pnpm scripts. WebStorm parses packet.json files, recognizing definitions of scripts, shows scripts in a tree view, and lets you navigate between a script in the tree and its definition in the package.json file. See npm, Yarn, and pnpm official web sites for details.
WebStorm detects projects with Yarn workspaces and indexes all the dependencies that are listed in the package.json files of the workspaces but are located in the root node_modules folder.
Before y'all first
-
Download and install Node.js. Note that npm is as well installed, so if you are going to use it, you are through with the preliminary steps.
-
To utilise Yarn, install it every bit described on the Yarn official website.
-
To use pnpm, open the embedded Terminal (Alt+F12) and type:
npm install --g pnpmLearn more than from the pnpm official website.
Choose a project bundle manager
With WebStorm, you can choose whether to use npm, Yarn, Yarn 2, or pnpm in a project.
Past default, WebStorm suggests npm. Notwithstanding if you open a project with a yarn.lock file and Yarn is installed on your computer, WebStorm automatically changes the bundle managing director for this project to Yarn.
Accordingly, if you open a project with a pnpm-lock file and pnpm is installed on your computer, WebStorm automatically changes the package manager for this project to pnpm.
You can also set up Yarn 1 or pnpm as default WebStorm package manager.
-
In the Settings/Preferences dialog (Ctrl+Alt+S), become to . The Node.js page opens.
-
In the Packet manager field, specify the packet manager for your project.
-
Select npm, yarn, or pnpm to use the system default installation.
-
To use a custom installation of a bundle manager, click Select, and select the installation folder of the relevant package manager.
WebStorm automatically uses the chosen packet manager when you select the
Projectalias from the Package manager listing in the Run/Debug Configuration: NPM dialog. WebStorm also uses the path to the chosen parcel managing director every time you invoke the Run 'npm install'/Run 'yarn install'/Run 'pnpm install' command or run an npm/Yarn/pnpm script, see Running and debugging scripts for details. -
Gear up Yarn 2 in your project
-
Brand sure yous have Yarn 1 installed globally and enable Yarn 2 in your project as described on the Yarn official website. Use the embedded Terminal Alt+F12 to blazon the commands.
-
In the Settings/Preferences dialog (Ctrl+Alt+S), go to and select the path to the Yarn ii package in your projection from the Parcel manager list.
Set up Yarn i or pnpm equally the default WebStorm package managing director
-
Open the Settings for New Projects dialog () and go to .
-
On the Node.js and NPM page that opens, select
yarnorpnpmfrom the Package manager listing.
After that, WebStorm volition suggest the selected package manager (Yarn or pnpm) every bit default every time you create a new project.
Edit parcel.json
WebStorm helps yous handle your project dependencies in package.json files providing extensive coding assistance.
-
Code completion for parcel names.
-
Information on the latest available package version.
-
Information about the range of versions that can be installed through
npm install <package>@<version>oryarn add <package>@<version>. `Note that runningnpm installoryarn installwill install the latest bachelor version from this range.Press Ctrl and hover over the version to see the information in a tooltip. Encounter the npm Official documentation for details about semantic versioning.
-
Code completion for previous parcel versions. When you lot printing Ctrl+Space or outset typing a version different from the latest i, WebStorm displays a suggestion listing with all the previous versions of the package.
-
Quick documentation look-up for packages.
Install and update packages
As yous may know, npm can install packages both globally or as project dependencies or development dependencies, larn more from the npm official website.
pnpm also installs packages globally or as project dependencies or development dependencies, learn more from the pnpm official website.
With Yarn, y'all tin install packages globally or as project dependencies, run into Yarn official website for details.
In WebStorm, packages tin can be installed in the editor, from a packet.json file, in the congenital-in Terminal Alt+F12, or on the Node.js page.
From bundle.json
Install your projection dependencies
-
Click the Run 'npm install', Run 'yarn install', or Run 'pnpm install' link in the popup:
WebStorm shows this popup when the dependencies are non installed yet or when they have changed. If you close the popup or plough it off by choosing Don't ask again, yous can still install the dependencies using the Run '<package_manager> install' action or in the built-in terminal.
If yous take accidentally dismissed this notification and now want to go it dorsum, press Ctrl+Shift+A, start typing
Enable notifications, and select Enable Notifications nigh Installing Dependencies from package.json from the list. -
Alternatively, open up the relevant package.json file in the editor or select it in the Project tool window and choose Run 'npm install' from the context menu.
Update your project dependencies
-
Click Run '<parcel director> install' in the popup.
WebStorm shows this popup every fourth dimension you open a project, update it from the version command, or edit a package.json.
-
WebStorm besides runs an inspection that checks whether the packages from
dependenciesordevDependenciesare installed and their versions match the specified range. If the inspection detects any mismatch, it suggests a quick-fix. To apply it, click the Run '<package manager> install' link.
-
WebStorm likewise detects packages for which later versions are available and provides a quick-fix when y'all hover over the packet version.
Alternatively, printing Alt+Enter and select Update <packet> to the latest version from the list:
In the built-in Terminal
In the embedded Terminal (Alt+F12) , type one of the following commands:
-
For global installation:
-
npm install --global <package_name> -
yarn global add <package_name> -
pnpm --global add together <package_name>
-
-
To install a package every bit a project dependency or a evolution dependency:
-
npm install --save <package_name>ornpm install --save-dev <package_name> -
yarn add <package_name> --dev -
pnpm add --relieve-dev <package_name>
-
Install all dependencies listed in a bundle.json file
In the embedded Terminal (Alt+F12) , type one of the following commands:
-
npm install -
yarn install -
pnpm install
As a result yous get all the dependencies listed in the packet.json from the current binder. Learn more than from Editing packet.json.
Run and debug scripts
You can launch npm, Yarn, or pnpm scripts from a package.json file in the editor, from a tree of scripts in the dedicated npm tool window, according to a dedicated run configuration, or automatically, equally a commencement-up or a before-launch task.
The results of script execution are displayed in the Run tool window. The tool window shows the npm or Yarn script output, reports the errors occurred, lists the packages or plugins that accept not been establish, etc. The name of the terminal executed script is displayed on the title bar of the tool window.
If yous launch a script debugging session, WebStorm opens the Debug tool window.
During a script debugging session, yous can step through the script, cease and resume the script execution, examine it when suspended, run JavaScript code snippets in the Debugger Console, and then on.
Run and debug scripts from package.json
WebStorm lets you rapidly launch single scripts from package.json files. To run or debug several scripts, use a run configuration or the npm tool window.
-
Open the package.json file in the editor, click
in the gutter side by side to the script, and cull Run <script_name> or Debug <script_name> from the context menu.
-
You tin can also run a script by pressing Ctrl+Shift+F10.
The script output is shown in the Run tool window.
If you launch a script in the debug manner, WebStorm opens the Debug tool window, where y'all can step through the script, end and resume the script execution, examine it when suspended, run JavaScript code snippets in the Debugger Console, and so on.
Run and debug scripts from the npm tool window
The npm tool window opens when you select a packet.json file in the Project tool window or open information technology in the editor and select Show npm Scripts from the context carte.
Every bit soon every bit you invoke npm, pnpm, or Yarn, the tool starts building a tree of scripts defined within the scripts belongings of the package.json file on which it was invoked.
If you lot have several bundle.json files in your project, you tin build a separate script tree for each of them and run scripts without dropping the previously congenital trees. Each tree is shown under a separate node.
Open the npm tool window if information technology is not opened yet
-
Select the required file in the Projection tool window or open up it in the editor and choose Evidence npm Scripts from the context menu.
The npm tool window opens showing the scripts tree built according to the selected or opened bundle.json file.
Build a tree of scripts in an already opened npm tool window
-
In the npm tool window, click
on the toolbar and cull the required package.json file from the list. By default, WebStorm shows the bundle.json file in the root of your project.
-
If you lot have some other parcel.json file, click Cull parcel.json and select the package.json file you need in the dialog that opens. WebStorm adds a new node with the path to the called package.json file on its championship and builds a scripts tree under the new node.
Re-build a tree
-
Switch to the required node and click
on the toolbar.
Sort the scripts in a tree by their names
-
Click
on the toolbar, choose Sort by from the bill of fare, and and so choose Proper noun.
By default, a tree shows the scripts in the guild in which they are defined in package.json (choice Definition order).
Run one script
-
Double-click the script.
-
Select the script in the tree and printing Enter or choose Run <script name> from the context carte du jour.
Debug 1 script
-
Select the script in the tree and cull Debug <script_name> from the context menu.
WebStorm opens the Debug tool window where you lot tin can step through the script, stop and resume the script execution, examine information technology when suspended, run JavaScript code snippets in the Debugger Console, then on.
Run or debug several scripts
-
Use the multiselect mode: hold Shift (for adjacent items) or Ctrl (for non-adjacent items) keys and select the required scripts, so choose Run or Debug from the context menu of the selection.
Run and debug scripts past a run configuration
When you run or debug scripts from the editor or from the npm tool window, WebStorm automatically creates temporary run configurations. Also using them, y'all tin create and launch your own npm run configurations.
-
From the main menu, select . Alternatively, select Edit Configurations from the listing on the toolbar.
-
Click
on the toolbar and select npm from the list. The Run/Debug Configuration: npm dialog opens.
-
Specify the CLI control to execute, the scripts to run (use blank spaces as separators), and the location of the package.json file where these scripts are defined. Optionally, type the command-line arguments for executing the scripts.
-
Specify the Node.js interpreter to apply. This can be a local Node.js interpreter or a Node.js on Windows Subsystem for Linux.
Optionally, specify the Node.js-specific selection parameters and the environment variables to be passed to Node.js.
-
Specify the package manager to use. If you choose the
Projectallonym, WebStorm volition use the default project package manager from the Node.js page. You can also choose the relevant package allonym (npm or yarn) or specify an explicit path to a custom installation of a package director. -
Select the newly created run configuration from the listing on the toolbar then click
or
next to the list.
The results of script execution are displayed in the Run tool window.
If yous click
, WebStorm opens the Debug tool window, where you tin stride through the script, terminate and resume the script execution, examine it when suspended, run JavaScript code snippets in the Debugger Panel, and so on.
Run scripts with Run Anything
Run Annihilation is a quick style to offset scripts.
-
Printing Ctrl twice or click
on the Navigation bar. The Run Anything popup opens.
-
Type
npm runoryarn runin the search field. Equally you blazon, WebStorm shows the matching scripts. Select the required one from the listing and press Enter.
To view the command output in the Run tool window, press Ctrl+Enter, to testify the output in the Debug tool window, press Shift+Enter.
Run scripts automatically on outset-up
If you have some scripts that you run on a regular basis, you can add the respective run configurations to a list of startup tasks. The tasks will be executed automatically on the project start-up.
-
In the Settings/Preferences dialog (Ctrl+Alt+Southward), get to .
-
On the Startup Tasks page that opens, click
on the toolbar.
-
From the listing, choose the required npm run configuration. The configuration is added to the list.
If no applicative configuration is available in the project, click
and choose Edit Configurations. Then ascertain a configuration with the required settings on the Run/Debug Configuration: NPM page that opens. When you salvage the new configuration it is automatically added to the listing of startup tasks.
Run scripts as earlier-launch tasks
-
Open the Run/debug configurations dialog dialog by choosing from the main menu, and select the required configuration from the listing or create it anew past clicking
and choosing the relevant run configuration type.
-
In the dialog that opens, click
in the Before launch area and choose Run npm script from the list.
-
In the NPM Script dialog that opens, specify the npm run/debug configuration settings.
npm, pnpm, and yarn in Docker
With WebStorm, you can edit package.json, install, update, and remove dependencies of a project in a Docker container just in the aforementioned way as you do it locally.
-
Make sure the Node.js, Node.js Remote Interpreter, and Docker required plugins are enabled on the Settings/Preferences | Plugins folio, tab Installed, see Managing plugins for details.
-
Download, install, and configure Docker as described in Docker
-
Configure a Node.js remote interpreter in Docker and fix it is as default in your project. Also make sure the packet manager associated with this remote interpreter is prepare as project default.
-
Go on as with local development: edit your package.json, manage you projection dependencies, and run or debug scripts.
Terminal modified: 15 Nov 2022
Source: https://www.jetbrains.com/help/webstorm/installing-and-removing-external-software-using-node-package-manager.html
Posted by: taylorbeated1958.blogspot.com

0 Response to "How To Install Node Dependencies"
Post a Comment