在为Angular

时间:2017-10-23 08:13:13

标签: angular typescript

我正在使用Angular 2版本。我曾经通过node.js命令提示符安装bootstrap。

npm install ngx-bootstrap --save

我添加了像这样的.csproj。这是通过章鱼在服务器上部署我的应用程序,但是我在本地计算机上构建解决方案时遇到了这个问题。

  

错误:命令“npm install ngx-bootstrap --save”退出代码   1。

Packages.json:

{
  "version": "1.0.0",
  "name": "mywizard-ad",
  "private": true,
  "scripts": {
    "build-Debug": "webpack --config webpack.debug.js --env.WebApiEnv dev",
    "build-Release": "webpack --config webpack.prod.js --env.WebApiEnv dev",
    "build-Prod": "webpack  --config webpack.prod.js --env.WebApiEnv prod",
    "build-Stage": "webpack --config webpack.prod.js --env.WebApiEnv stage",
    "build-UAT": "webpack --config webpack.prod.js --env.WebApiEnv uat",
    "build-Preprod": "webpack --config webpack.prod.js --env.WebApiEnv preprod",
    "build-Prod_EU": "webpack --config webpack.prod.js --env.WebApiEnv prod_eu",
    "build-Stage_EU": "webpack --config webpack.prod.js --env.WebApiEnv stage_eu",
    "build-Hotfix": "webpack --config webpack.prod.js --env.WebApiEnv hotfix"
  },
  "dependencies": {
    "@angular/common": "~4.3.1",
    "@angular/core": "~4.3.1",
    "@angular/http": "~4.3.1",
    "@angular/platform-browser": "~4.3.1",
    "@angular/platform-browser-dynamic": "~4.3.1",
    "@angular/router": "~4.3.1",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.4",
    "@types/jquery": "^3.2.12",
    "angular2-moment": "^1.7.0",
    "core-js": "^2.4.1",
    "file-saver": "^1.3.3",
    "html-webpack-plugin": "^2.30.1",
    "jquery": "^3.2.1",
    "ng2-simple-global": "^1.2.5",
    "ngx-bootstrap": "^2.0.0-beta.7",
    "rxjs": "^5.1.0",
    "systemjs": "0.19.39",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/common": "~4.3.1",
    "@angular/compiler": "~4.3.1",
    "@angular/core": "~4.3.1",
    "@angular/forms": "~4.3.1",
    "@angular/http": "~4.3.1",
    "@angular/platform-browser": "~4.3.1",
    "@angular/platform-browser-dynamic": "~4.3.1",
    "@angular/router": "~4.3.1",
    "@ng-bootstrap/ng-bootstrap": "^1.0.0-beta.4",
    "@types/file-saver": "0.0.1",
    "@types/node": "^6.0.45",
    "clean-webpack-plugin": "^0.1.16",
    "core-js": "^2.4.1",
    "html-loader": "^0.5.1",
    "html-webpack-plugin": "^2.30.1",
    "jquery": "^3.2.1",
    "ng2-simple-global": "^1.2.5",
    "rxjs": "^5.1.0",
    "systemjs": "0.19.39",
    "typescript": "^2.0.0",
    "webpack": "^3.5.6",
    "webpack-concat-plugin": "^1.4.1",
    "webpack-merge": "^4.1.0",
    "zone.js": "^0.8.4"
  },
  "repository": {}
}

1 个答案:

答案 0 :(得分:1)

此问题与npm无关,而与my.csproj文件中的设置无关。实际上,您无需使用此文件来安装npm modules。 Visual Studio使用.csproj文件来组织您的项目。因此,您无需为依赖项编辑它们。

npm标记--save会将模块保存为package.json中的依赖项。当你git clone项目时它很有用。克隆项目后,npm install将使用标记--save安装先前安装的所有软件包。您不需要在.csproj文件中包含这些行,特别是如果它们使npm install失败。

你可以试试这个:

  • 评论my.csproj文件
  • 中的行
  • 在本地手动运行命令(您可以检查您的“package.json”中是否有与这些依赖项相对应的条目;如果它们已经存在,则表示已经安装了所有依赖项,即您可以跳过这一步)
  • 提交新的“package.json”文件