我有一个简单的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
grunt-sass@2.0.0 requires a peer of grunt@>=0.4.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-rating@1.0.6 requires a peer of react@>=0.13.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-bootstrap-typeahead@2.5.1 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
react-bootstrap-typeahead@2.5.1 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
prop-types-extra@1.0.1 requires a peer of react@>=0.14.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-overlays@0.8.3 requires a peer of react@^0.14.9 || >=15.3.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-overlays@0.8.3 requires a peer of react-dom@^0.14.9 || >=15.3.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-onclickoutside@6.7.1 requires a peer of react@^15.5.x || ^16.x but none is installed. You must install peer dependencies yourself.
npm
WARN
react-onclickoutside@6.7.1 requires a peer of react-dom@^15.5.x || ^16.x but none is installed. You must install peer dependencies yourself.
npm
WARN
react-transition-group@2.2.1 requires a peer of react@>=15.0.0 but none is installed. You must install peer dependencies yourself.
npm
WARN
react-transition-group@2.2.1 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
和其他文件。
安装组件的正确方法是什么?
cd && npm root
并将输出粘贴在这里吗? - Alexey Andrushkevichnpm
。通过按Win-R打开常规命令行应用程序,然后键入“cmd”命令来打开终端窗口。然后在终端窗口中导航到您的项目,然后像您上面所述那样运行“npm install”命令。 - Alexey Andrushkevich