Angular中的“ ng build”

时间:2019-02-28 13:56:17

标签: angular npm package

当我在项目中启动“ ng build”时,出现以下错误:

ERROR in ../../node_modules/@auth0/angular-jwt/index.d.ts(1,47): error TS2307: Cannot find module '@angular/core'. ../../node_modules/@auth0/angular-jwt/src/jwt.interceptor.d.ts(1,70): error TS2307: Cannot find module '@angular/common/http'. ../../node_modules/@auth0/angular-jwt/src/jwt.interceptor.d.ts(3,28): error TS2307: Cannot find module 'rxjs/internal/Observable'. ../../node_modules/@auth0/angular-jwt/src/jwtoptions.token.d.ts(1,32): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/accordion/accordion-group.component.d.ts(1,49): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/accordion/accordion.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/alert/alert.component.d.ts(1,57): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/alert/alert.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/buttons/button-checkbox.directive.d.ts(1,34): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/buttons/button-checkbox.directive.d.ts(2,38): error TS2307: Cannot find module '@angular/forms'. ../../node_modules/ngx-bootstrap/buttons/button-radio-group.directive.d.ts(1,45): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/buttons/button-radio-group.directive.d.ts(2,38): error TS2307: Cannot find module '@angular/forms'. ../../node_modules/ngx-bootstrap/buttons/button-radio.directive.d.ts(1,76): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/buttons/button-radio.directive.d.ts(2,38): error TS2307: Cannot find module '@angular/forms'. ../../node_modules/ngx-bootstrap/buttons/buttons.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/carousel/carousel.component.d.ts(17,49): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/carousel/carousel.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/carousel/slide.component.d.ts(1,35): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/collapse/collapse.directive.d.ts(1,53): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/collapse/collapse.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/component-loader/bs-component-ref.class.d.ts(1,47): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/component-loader/component-loader.class.d.ts(1,197): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/component-loader/component-loader.factory.d.ts(1,117): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/component-loader/content-ref.class.d.ts(5,39): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/base/bs-datepicker-container.d.ts(3,28): error TS2307: Cannot find module 'rxjs'. ../../node_modules/ngx-bootstrap/datepicker/bs-datepicker-inline.component.d.ts(1,116): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/bs-datepicker-inline.component.d.ts(3,30): error TS2307: Cannot find module 'rxjs'. ../../node_modules/ngx-bootstrap/datepicker/bs-datepicker-input.directive.d.ts(1,58): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/bs-datepicker-input.directive.d.ts(2,84): error TS2307: Cannot find module '@angular/forms'. ../../node_modules/ngx-bootstrap/datepicker/bs-datepicker.component.d.ts(1,116): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/bs-datepicker.component.d.ts(3,30): error TS2307: Cannot find module 'rxjs'. ../../node_modules/ngx-bootstrap/datepicker/bs-datepicker.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/bs-daterangepicker-input.directive.d.ts(1,58): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/bs-daterangepicker-input.directive.d.ts(2,84): error TS2307: Cannot find module '@angular/forms'. ../../node_modules/ngx-bootstrap/datepicker/bs-daterangepicker.component.d.ts(1,116): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/bs-daterangepicker.component.d.ts(3,30): error TS2307: Cannot find module 'rxjs'. ../../node_modules/ngx-bootstrap/datepicker/bs-locale.service.d.ts(1,45): error TS2307: Cannot find module 'rxjs'. ../../node_modules/ngx-bootstrap/datepicker/datepicker-inner.component.d.ts(1,64): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/datepicker.component.d.ts(1,40): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/datepicker.component.d.ts(2,38): error TS2307: Cannot find module '@angular/forms'. ../../node_modules/ngx-bootstrap/datepicker/datepicker.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/daypicker.component.d.ts(1,24): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/monthpicker.component.d.ts(1,24): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/reducer/bs-datepicker.effects.d.ts(1,28): error TS2307: Cannot find module 'rxjs'. ../../node_modules/ngx-bootstrap/datepicker/themes/bs/bs-datepicker-container.component.d.ts(1,49): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/themes/bs/bs-datepicker-container.component.d.ts(8,30): error TS2307: Cannot find module 'rxjs'. ../../node_modules/ngx-bootstrap/datepicker/themes/bs/bs-datepicker-day-decorator.directive.d.ts(1,47): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/themes/bs/bs-datepicker-inline-container.component.d.ts(1,35): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/themes/bs/bs-datepicker-navigation-view.component.d.ts(1,30): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/themes/bs/bs-daterangepicker-container.component.d.ts(1,49): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/themes/bs/bs-daterangepicker-container.component.d.ts(8,30): error TS2307: Cannot find module 'rxjs'. ../../node_modules/ngx-bootstrap/datepicker/themes/bs/bs-days-calendar-view.component.d.ts(1,30): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/themes/bs/bs-months-calendar-view.component.d.ts(1,30): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/themes/bs/bs-years-calendar-view.component.d.ts(1,30): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/datepicker/yearpicker.component.d.ts(1,24): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/dropdown/bs-dropdown-container.component.d.ts(1,69): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/dropdown/bs-dropdown-menu.directive.d.ts(1,47): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/dropdown/bs-dropdown-toggle.directive.d.ts(1,39): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/dropdown/bs-dropdown.directive.d.ts(1,90): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/dropdown/bs-dropdown.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/dropdown/bs-dropdown.state.d.ts(1,30): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/mini-ngrx/state.class.d.ts(5,45): error TS2307: Cannot find module 'rxjs'. ../../node_modules/ngx-bootstrap/mini-ngrx/store.class.d.ts(4,48): error TS2307: Cannot find module 'rxjs'. ../../node_modules/ngx-bootstrap/modal/bs-modal.service.d.ts(1,75): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/modal/modal-backdrop.component.d.ts(1,47): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/modal/modal-container.component.d.ts(1,58): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/modal/modal.directive.d.ts(1,104): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/modal/modal.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/pagination/pager.component.d.ts(1,79): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/pagination/pager.component.d.ts(2,38): error TS2307: Cannot find module '@angular/forms'. ../../node_modules/ngx-bootstrap/pagination/pagination.component.d.ts(1,79): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/pagination/pagination.component.d.ts(2,38): error TS2307: Cannot find module '@angular/forms'. ../../node_modules/ngx-bootstrap/pagination/pagination.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/popover/popover.directive.d.ts(1,103): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/popover/popover.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/positioning/positioning.service.d.ts(1,28): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/progressbar/bar.component.d.ts(1,35): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/progressbar/progressbar.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/rating/rating.component.d.ts(1,70): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/rating/rating.component.d.ts(2,38): error TS2307: Cannot find module '@angular/forms'. ../../node_modules/ngx-bootstrap/rating/rating.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/sortable/draggable-item.service.d.ts(1,25): error TS2307: Cannot find module 'rxjs'. ../../node_modules/ngx-bootstrap/sortable/sortable.component.d.ts(1,43): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/sortable/sortable.component.d.ts(2,38): error TS2307: Cannot find module '@angular/forms'. ../../node_modules/ngx-bootstrap/sortable/sortable.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/tabs/ng-transclude.directive.d.ts(1,47): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/tabs/tab-heading.directive.d.ts(1,29): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/tabs/tab.directive.d.ts(1,85): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/tabs/tabs.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/tabs/tabset.component.d.ts(1,38): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/timepicker/models/index.d.ts(1,32): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/timepicker/models/index.d.ts(2,38): error TS2307: Cannot find module '@angular/forms/src/directives/control_value_accessor'. ../../node_modules/ngx-bootstrap/timepicker/models/index.d.ts(3,22): error TS2307: Cannot find module '@angular/core/src/type'. ../../node_modules/ngx-bootstrap/timepicker/timepicker.component.d.ts(1,86): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/timepicker/timepicker.component.d.ts(2,38): error TS2307: Cannot find module '@angular/forms'. ../../node_modules/ngx-bootstrap/timepicker/timepicker.component.d.ts(7,30): error TS2307: Cannot find module 'rxjs'. ../../node_modules/ngx-bootstrap/timepicker/timepicker.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/tooltip/tooltip-container.component.d.ts(1,31): ../../node_modules/ngx-bootstrap/typeahead/typeahead.directive.d.ts(1,122): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/typeahead/typeahead.directive.d.ts(2,27): error TS2307: Cannot find module '@angular/forms'. ../../node_modules/ngx-bootstrap/typeahead/typeahead.module.d.ts(1,37): error TS2307: Cannot find module '@angular/core'. ../../node_modules/ngx-bootstrap/utils/triggers.d.ts(5,27): error TS2307: Cannot find module '@angular/core'. 为什么会有这些错误?

2 个答案:

答案 0 :(得分:1)

  1. 确保您位于项目文件夹中:

  2. 我认为您已经看过Angular quick start guide并且已经运行:

    npm install -g @angular/cli

  3. 如果您下载了没有所有依赖库的现有压缩项目,请运行

    npm install

    • 有效地,它将在 node_modules 文件夹
    • 中创建条目
    • 在项目文件夹中的 package.json 中。

    • 可以找到更多here

  4. 运行您的ng build。更多信息here

让我知道这是否有帮助。

答案 1 :(得分:0)

Package.json文件:

{   “ name”:“ pwa-spa”,   “ version”:“ 0.0.0”,   “脚本”:{     “ ng”:“ ng”,     “ start”:“ ng服务”,     “ build”:“ ng build”,     “ test”:“ ng test”,     “ lint”:“ ng lint”,     “ e2e”:“ ng e2e”   },   “私人”:是的,   “依赖关系”:{     “ @ angular / animations”:“ ^ 6.0.3”,     “ @ angular / cdk”:“ ^ 7.3.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 / material”:“ ^ 7.3.3”,     “ @ angular / platform-b​​rowser”:“ ^ 6.0.3”,     “ @ angular / platform-b​​rowser-dynamic”:“ ^ 6.0.3”,     “ @ angular / pwa”:“ ^ 0.13.1”,     “ @ angular / router”:“ ^ 6.0.3”,     “ @ angular / service-worker”:“ ^ 6.0.3”,     “ core-js”:“ ^ 2.5.4”,     “ 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 /茉莉花”:“〜2.8.6”,     “ @ types / jasminewd2”:“〜2.0.3”,     “ @ types / node”:“〜8.9.4”,     “ codelyzer”:“〜4.2.1”,     “茉莉花芯”:“〜2.99.1”,     “ jasmine-spec-reporter”:“〜4.2.1”,     “ karma”:“〜1.7.1”,     “ karma-chrome-launcher”:“〜2.2.0”,     “业报-伊斯坦布尔报道”:“〜2.0.0”,     “业力茉莉花”:“〜1.1.1”,     “ karma-jasmine-html-reporter”:“ ^ 0.2.2”,     “量角器”:“〜5.3.0”,     “ ts-node”:“〜5.0.1”,     “ tslint”:“〜5.9.1”   } }