Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I execute npm commands directly from the visual studio

Can I execute npm commands (e.g. npm init, npm install) directly from Visual Studio 2017 on Asp.Net Core 2.0 project? May be from command line or context menu? Now I have context menu command for Bower, when right click on MVC project in Solution Explorer, but i'm not use bower in my project.

like image 642
Anton Gorbunov Avatar asked Nov 20 '17 08:11

Anton Gorbunov


People also ask

How do I run npm in Visual Studio?

To open the package manager, from Solution Explorer, right-click the npm node in your project. Next, you can search for npm packages, select one, and install by selecting Install Package.

Where do I run npm commands?

You should run it in your project root folder, or the folder above your node_modules folder as sometimes the structure can differentiate between projects. But in general: the root folder of your project, as long as it is one folder above your node_modules.

How do I run npm locally?

You can do this by running npm link followed by the name of the local package. In this demo, the name of the package we want to test is jqq-package so you would run npm link jqq-package , but make sure to use the specific name of the package you are testing.


3 Answers

You can use the Package Manager Console like you would a regular console. The Package Manager Console in Visual Studio acts like a PowerShell console. NPM commands such as init and install are available if npm is on your classpath.

The Package Manager Console is found under Tools -> NuGet Package Manager -> Package Manager Console.

like image 107
nbokmans Avatar answered Oct 21 '22 14:10

nbokmans


Another solution if you want separate window instead of Package Manager Console: NPM task runner extension

This tool will add fancy window to run commands from package.json file (I assume you have one)

like image 27
Denis Krasakov Avatar answered Oct 21 '22 15:10

Denis Krasakov


There is a new tool included in Visual Studio v15.8 called Library Manager for installing client side libraries. I've been trying it out after looking for a quick and easy solution to install NPM packages, and I must say it has been a pleasure to use!

You can install any NPM package by simply selecting the UnPkg provider in the GUI, or setting it in your libman.json file, like so:

"defaultProvider": "UnPkg"

Fast, lightweight, and works like a charm. Give it a try!

like image 1
Shahin Dohan Avatar answered Oct 21 '22 14:10

Shahin Dohan