I have a simple Visual Studio solution, running ASP.NET Core v2 and building a React app.
Now, I want to install a simple component using the NPM. In this particular example, it could be:
npm install --save react-bootstrap-typeahead
I want this package to work just in my solution and nowhere else.
My result:
When I run this, I get the following nice error which obviously makes some sense. If NPM believes it can find my project file at 'C:UsersLarsHoldgaardpackage.json', it’s out of luck. The correct path would be C:UsersLarsHoldgaardDocumentsGithubLikvido.CreditRiskLikvido.CreditRiskLikvido.CreditRisk .
npm : npm WARN saveError ENOENT: no such file or directory, open 'C:UsersLarsHoldgaardpackage.json'
At line:1 char:1
+ npm install --save react-bootstrap-typeahead
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (npm WARN saveEr...dpackage.json':String) [], RemoteException
+ FullyQualifiedErrorId : NativeCommandError
npm
WARN
enoent
ENOENT: no such file or directory, open 'C:UsersLarsHoldgaardpackage.json'
npm
WARN
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f89f8a8d968cd58b998b8bb8cad6c8d6c8">[email protected]</a> requires a peer of <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4f283d3a213b0f">[email protected]</a>>=0.4.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="acdec9cdcfd881decdd8c5c2cbec9d829c829a">[email protected]</a> requires a peer of <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="592b3c383a2d19">[email protected]</a>>=0.13.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="4e3c2b2f2d3a632c21213a3d3a3c2f3e633a373e2b2f262b2f2a0e7c607b607f">[email protected]</a> requires a peer of <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="7b091e1a180f3b">[email protected]</a>^0.14.0 || ^15.2.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="92e0f7f3f1e6bff0fdfde6e1e6e0f3e2bfe6ebe2f7f3faf7f3f6d2a0bca7bca3">[email protected]</a> requires a peer of <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="dba9bebab8aff6bfb4b69b">[email protected]</a>^0.14.0 || ^15.2.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f181839e81dc8588819482dc9489858390b1c0dfc1dfc0">[email protected]</a> requires a peer of <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="f88a9d999b8cb8">[email protected]</a>>=0.14.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6f1d0a0e0c1b4200190a1d030e161c2f5f4157415c">[email protected]</a> requires a peer of <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="9ceef9fdffe8dc">[email protected]</a>^0.14.9 || >=15.3.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="384a5d595b4c15574e5d4a5459414b78081600160b">[email protected]</a> requires a peer of <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="6614030705124b02090b26">[email protected]</a>^0.14.9 || >=15.3.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="bcced9dddfc891d3d2dfd0d5dfd7d3c9c8cfd5d8d9fc8a928b928d">[email protected]</a> requires a peer of <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="73011612100733">[email protected]</a>^15.5.x || ^16.x but none is installed. You must install peer dependencies yourself.
npm
WARN
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d4a6b1b5b7a0f9bbbab7b8bdb7bfbba1a0a7bdb0b194e2fae3fae5">[email protected]</a> requires a peer of <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d9abbcb8baadf4bdb6b499">[email protected]</a>^15.5.x || ^16.x but none is installed. You must install peer dependencies yourself.
npm
WARN
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="91e3f4f0f2e5bce5e3f0ffe2f8e5f8feffbcf6e3fee4e1d1a3bfa3bfa0">[email protected]</a> requires a peer of <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="88faede9ebfcc8">[email protected]</a>>=15.0.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
<a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="b4c6d1d5d7c099c0c6d5dac7ddc0dddbda99d3c6dbc1c4f4869a869a85">[email protected]</a> requires a peer of <a href="https://getridbug.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="5c2e393d3f28713833311c">[email protected]</a>>=15.0.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
LarsHoldgaard No description
npm
WARN
LarsHoldgaard No repository field.
npm
WARN
LarsHoldgaard No README data
npm
WARN
LarsHoldgaard No license field.
My thinking:
Being a console noob, I would guess I just needed to change my current folder. But if I run dir, I am in the right folder, and I can see my package.json along with other files.
What is the right way to install components?
Answers:
Thank you for visiting the Q&A section on Magenaut. Please note that all the answers may not help you solve the issue immediately. So please treat them as advisements. If you found the post helpful (or not), leave a comment & I’ll get back to you as soon as possible.
Method 1
To avoid navigating manually to the correct directory use the “Open Command Line” extension from Mads Kristensen. It is available for free in the Marketplace. You find it here.
Once installed you can open a command prompt conviently directly from within Visual Studio.
Tipp: Use the Keyboard Shortcut ALT+Space instead of the context menu to open the command prompt.
You can then run your npm command:
npm install react-bootstrap-typeahead
As a side note: As of npm 5.0.0, installed modules are added as a dependency by default, so the –save option is no longer required.
Update 2019:
Developer Command Prompt and Developer Power Shell are now integrated into Visual Studio 2019 ( 16.2 Preview 2 ) – no need for an extension anymore.
You find them under Tools/Command Line
By default no shortcut is assigned – so you have to do this yourself.
Method 2
I think the easiest way is to simple use the UI, Visual Studio provides.
Create in the root of your project a package.json (Todo so, right click your project, add item and search for NPM. You will find a npm Configuration File):
{
"name": "SomeName",
"version": "1.0.0",
"private": true,
"devDependencies": {
"react-bootstrap-typeahead": "*"
}
}
Note that * is for the latest version. This is not recommended. Better to specify the version you want. You will notice, that you have support of intellisence for versions and package names.
Everytime you make changes to the json file, simple press CTRL + S. Visual Studio automaticly calls NPM and restores the packages.
For how to use the command line, other have already answerd. But as being a command line noob myself, I prefer this way.
Method 3
You can use the Package Manager Console to run npm command.
To open the Package Manager Console, go to Tools > Nuget Package Manager and select Package Manager Console and then enter your npm command.
Update:
The latest visual studio 16.8.3 onwards, you will find the terminal built into visual studio.
You can find it by right-clicking at your solution or a shortcut Ctrl + `:

Method 4
- In Window’s Explorer, navigate to where the
package.jsonfile is located in your project. - Create a folder named
node_modulesin the same directory as yourpackage.jsonfile - While holding the left
[Shift]key, right click in the folder containing theproject.jsonfile. - From the context menu select ‘Open command window here’.
- Input your npm command
npm install --save react-bootstrap-typeahead
Method 5
I use a different approach, configuring npm per SOLUTION, instead of per PROJECT.
Please refer to my BLOG:
A better way to use Visual Studio with npm ( and Gulp )
It is working fine and you may use Command Line ou Package Manager Console do install/update/uninstall npm packages.
I am currently using it with Visual Studio 2019 and ASP.NET Core MVC.
Method 6
Adding my 2 cents from 2021.
Visual Studio comes with built-in npm support, no CLI required. VS can automatically install/restore packages in the background – on project open and/or after making changes to packages.json file. You can enable this here:
For example, here’s an article about configuring automatic minification and compilation for js/css files via npm tool, using just naked Visual Studio (DISCLAIMER: I wrote that blog post myself last year)
All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0





