Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jquery-ui/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
运行Angular应用程序时出错_Angular_Angular Bootstrap_Ngx Bootstrap_Ngx Bootstrap Modal_Angular Bootstrap Calendar - Fatal编程技术网

运行Angular应用程序时出错

运行Angular应用程序时出错,angular,angular-bootstrap,ngx-bootstrap,ngx-bootstrap-modal,angular-bootstrap-calendar,Angular,Angular Bootstrap,Ngx Bootstrap,Ngx Bootstrap Modal,Angular Bootstrap Calendar,我已经在Angular应用程序中安装了ngx引导,以使用日期选择器 现在运行Angular应用程序时出现错误 我把错误的细节放在下面 多../node_模块/bootstrap/dist/css/bootstrap.min.css中出错 ../node_modules/ngx bootstrap/datepicker/bs-datepicker.css ./src/styles.css 未找到模块:错误:无法解析“/Users/user/Projects/node\u modules/boots

我已经在Angular应用程序中安装了ngx引导,以使用日期选择器

现在运行Angular应用程序时出现错误

我把错误的细节放在下面

多../node_模块/bootstrap/dist/css/bootstrap.min.css中出错 ../node_modules/ngx bootstrap/datepicker/bs-datepicker.css ./src/styles.css

未找到模块:错误:无法解析“/Users/user/Projects/node\u modules/bootstrap/dist/css/bootstrap.min.css” 在“/Users/user/Projects/CRUD”中 多../node_模块/bootstrap/dist/css/bootstrap.min.css中出错 ../node_modules/ngx bootstrap/datepicker/bs-datepicker.css ./src/styles.css

未找到模块:错误:无法解析“/Users/user/Projects/node_modules/ngx bootstrap/datepicker/bs datepicker.css” 在“/Users/user/Projects/CRUD”中

我将angular.json文件代码放在下面

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "CRUD": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/CRUD",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "../node_modules/bootstrap/dist/css/bootstrap.min.css",
              "../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
              "src/styles.css"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "CRUD:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "CRUD:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "CRUD:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "styles": [
              "src/styles.css"
            ],
            "scripts": [],
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "CRUD-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "CRUD:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "CRUD:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "CRUD"
}
{
  "name": "crud",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.3",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "bootstrap": "^3.3.7",
    "core-js": "^2.5.4",
    "ngx-bootstrap": "^3.0.1",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.3",
    "@angular-devkit/build-angular": "~0.6.8",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.8",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1"
  }
}
Package.json代码-:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "CRUD": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "prefix": "app",
      "schematics": {},
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist/CRUD",
            "index": "src/index.html",
            "main": "src/main.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.app.json",
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ],
            "styles": [
              "../node_modules/bootstrap/dist/css/bootstrap.min.css",
              "../node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
              "src/styles.css"
            ],
            "scripts": []
          },
          "configurations": {
            "production": {
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ],
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "CRUD:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "CRUD:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "CRUD:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "karmaConfig": "src/karma.conf.js",
            "styles": [
              "src/styles.css"
            ],
            "scripts": [],
            "assets": [
              "src/favicon.ico",
              "src/assets"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    },
    "CRUD-e2e": {
      "root": "e2e/",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "e2e/protractor.conf.js",
            "devServerTarget": "CRUD:serve"
          },
          "configurations": {
            "production": {
              "devServerTarget": "CRUD:serve:production"
            }
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": "e2e/tsconfig.e2e.json",
            "exclude": [
              "**/node_modules/**"
            ]
          }
        }
      }
    }
  },
  "defaultProject": "CRUD"
}
{
  "name": "crud",
  "version": "0.0.0",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/animations": "^6.0.3",
    "@angular/common": "^6.0.3",
    "@angular/compiler": "^6.0.3",
    "@angular/core": "^6.0.3",
    "@angular/forms": "^6.0.3",
    "@angular/http": "^6.0.3",
    "@angular/platform-browser": "^6.0.3",
    "@angular/platform-browser-dynamic": "^6.0.3",
    "@angular/router": "^6.0.3",
    "bootstrap": "^3.3.7",
    "core-js": "^2.5.4",
    "ngx-bootstrap": "^3.0.1",
    "rxjs": "^6.0.0",
    "zone.js": "^0.8.26"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^6.0.3",
    "@angular-devkit/build-angular": "~0.6.8",
    "typescript": "~2.7.2",
    "@angular/cli": "~6.0.8",
    "@angular/language-service": "^6.0.3",
    "@types/jasmine": "~2.8.6",
    "@types/jasminewd2": "~2.0.3",
    "@types/node": "~8.9.4",
    "codelyzer": "~4.2.1",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~1.7.1",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.0",
    "karma-jasmine": "~1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.3.0",
    "ts-node": "~5.0.1",
    "tslint": "~5.9.1"
  }
}
第一步

Inside .angular-cli.json file
“风格”:[ “styles.css”, “./node_modules/bootstrap/dist/css/bootstrap.min.css”]

删除“./node\u模块/bootstrap/dist/css/bootstrap.min.css”

第二步

Go to styles.css
通过添加此行导入引导

@import "~bootstrap/dist/css/bootstrap.css";

这些步骤解决了我在构建过程中遇到的错误。

您从错误的位置导入了
css
文件

更新
angular.json
文件:

"styles": [
          "node_modules/bootstrap/dist/css/bootstrap.min.css",
          "node_modules/ngx-bootstrap/datepicker/bs-datepicker.css",
          "src/styles.css"
        ],

请从angular.json文件中删除行
“node\u modules/bootstrap/dist/css/bootstrap.min.css”
。这将修复您的错误

这一行用于引导

当您删除这一行时,您将失去引导提供的更好的前端外观

如果您还想继续体验bootstrap,请先安装bootstrap

要安装引导程序,请在终端中启动此命令
npm install bootstrap--save

然后将angular.json更改如下

"styles": [
    "node_modules/bootstrap/dist/css/bootstrap.min.css",
     "styles.css"]
将引导文件保持在样式数组列表的顶部是很重要的


希望一切都好。Chee编码:)

直接在html文件中导入bootstrap.min.css和bs-datepicker.css。从angular.json文件中删除。嗨,如果@AmbujKhanna提出的解决方案不起作用,请发布您的package.json或angular.json以及您要导入的模块如果上述解决方案不起作用,那么您可以尝试在“style.CSS”之后导入这两个CSS在你的angular.json文件中。@AmbujKhanna你在app.module中导入了所有依赖的模块吗?@rick您好我上传了package.json和angular.json请查看itI我仍然收到错误,我上传了package.json和angular.json代码,请查看。请更改CSS文件的顺序。“样式”:[“./node_modules/bootstrap/dist/css/bootstrap.min.css”,“./node_modules/ngx bootstrap/datepicker/bs datepicker.css”,“src/styles.css”],他试图保持引导。这就是全部,不是吗?