如何在Visual Studio 2017中使用NPM并安装软件包?

拉尔斯·霍尔德(Lars Holdgaard):

我有一个简单的Visual Studio解决方案,运行ASP.NET Core v2并构建一个React应用程序。

现在,我想使用NPM安装一个简单的组件。在此特定示例中,可能是:

npm install --save react-bootstrap-typeahead

我希望此程序包仅在我的解决方案中起作用,而在其他地方也不能起作用。

我的结果:

当我运行此命令时,我得到以下明显的错误,这显然是有道理的。如果NPM认为可以在找到我的项目文件'C:\Users\LarsHoldgaard\package.json',那真是倒霉。正确的路径是C:\Users\LarsHoldgaard\Documents\Github\Likvido.CreditRisk\Likvido.CreditRisk\Likvido.CreditRisk

npm : npm WARN saveError ENOENT: no such file or directory, open 'C:\Users\LarsHoldgaard\package.json'
At line:1 char:1
+ npm install --save react-bootstrap-typeahead
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (npm WARN saveEr...d\package.json':String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

npm

WARN

enoent
 ENOENT: no such file or directory, open 'C:\Users\LarsHoldgaard\package.json'

npm

WARN
 [email protected] requires a peer of grunt@>=0.4.0 but none is installed. You must install peer dependencies yourself.

npm

WARN
 [email protected] requires a peer of react@>=0.13.0 but none is installed. You must install peer dependencies yourself.

npm

WARN
 [email protected] requires a peer of react@^0.14.0 || ^15.2.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.

npm

WARN
 [email protected] requires a peer of react-dom@^0.14.0 || ^15.2.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.

npm

WARN
 [email protected] requires a peer of react@>=0.14.0 but none is installed. You must install peer dependencies yourself.

npm

WARN
 [email protected] requires a peer of react@^0.14.9 || >=15.3.0 but none is installed. You must install peer dependencies yourself.

npm

WARN
 [email protected] requires a peer of react-dom@^0.14.9 || >=15.3.0 but none is installed. You must install peer dependencies yourself.

npm

WARN
 [email protected] requires a peer of react@^15.5.x || ^16.x but none is installed. You must install peer dependencies yourself.

npm

WARN
 [email protected] requires a peer of react-dom@^15.5.x || ^16.x but none is installed. You must install peer dependencies yourself.

npm

WARN
 [email protected] requires a peer of react@>=15.0.0 but none is installed. You must install peer dependencies yourself.

npm

WARN
 [email protected] requires a peer of react-dom@>=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.

我的想法:

作为控制台菜鸟,我想我只需要更改当前文件夹即可。但是,如果运行dir,我将位于正确的文件夹中,并且可以看到package.json其他文件。

什么是安装组件的正确方法?

明信片:

为避免手动导航到正确的目录,请使用Mads Kristensen的“ Open Command Line”扩展名。它在市场中免费提供。您可以在这里找到它

安装后,您可以直接在Visual Studio中方便地打开命令提示符。

在此处输入图片说明

提示:使用键盘快捷键ALT +空格键而不是上下文菜单可以打开命令提示符。

然后,您可以运行npm命令:

npm install react-bootstrap-typeahead

附带说明:从npm 5.0.0开始,默认情况下已安装模块作为依赖项添加,因此不再需要--save选项。

更新2019

开发人员命令提示符和开发人员Power Shell现在已集成到Visual Studio 2019(16.2 Preview 2)中-不再需要扩展。

你在下面找到它们 Tools/Command Line

默认情况下,没有分配快捷方式-因此您必须自己执行此操作。

在此处输入图片说明

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

如何在Visual Studio Code中的Java项目中制作软件包

如何在Visual Studio 2017中使用Java

项目设置中缺少Visual Studio 2017软件包选项卡

更改Visual Studio 2017使用的NuGet软件包文件夹

如何在Visual Studio中启用NuGet软件包还原?

如何在Visual Studio 2015中禁用NPM软件包还原?

如何在Visual Studio中使用Bower(从nuget安装)?

如何在Visual Studio团队服务的构建和发布管理中使用私有npm软件包提要

如何在Vue SPA中使用npm软件包

如何在TFS Visual Studio构建步骤中使用Visual Studio 2017

什么是Microsoft.DependencyValidation.Analyser?为什么Visual Studio 2017强制安装该软件包?

如何在Visual Studio 2017中使用Qt库?

如何在ReasonML中使用npm软件包?

如何在Visual Studio 2017中使用Jupyter Notebook?

如何在Visual Studio 2017中为C ++安装Npgsql

无法在Visual Studio中安装任何软件包

如何在Visual Studio 2017项目中安装的_Layout中引用npm软件包?

如何在.js文件中使用npm安装的软件包?

如何使用从Laravel中的npm安装的软件包

如何在Dockerfile中使用miniconda安装软件包?

如何在Visual Studio中使用IntelliCode?

Visual Studio代码扩展-npm安装由于软件包依赖关系而失败?

如何在Visual Studio中使用PhoneGap

创建Visual Studio扩展软件包安装程序

如何在React中使用Bootstrap npm软件包

如何在Visual Studio中使用Startswith

如何在 python 应用程序中使用 Visual Studio 2017 中的用户包

如何在 Visual Studio 2017 中添加和使用图像?

如何在 Visual Studio 2017 中使 != 变为 ==