English 中文(简体)
Angular 6 - 无法找到“@angular-devkit/build-angular”模块
原标题:Angular 6 - Could not find module "@angular-devkit/build-angular"

在更新为6.0.1之后,我在<编码>纳克/代码>上发现了以下错误:

Could not find module "@angular-devkit/build-angular" from "/home/Projects/myProjectName".
Error: Could not find module "@angular-devkit/build-angular" from "/home/Projects/myProjectName".
    at Object.resolve (/home/Projects/myProjectName/node_modules/@angular-devkit/core/node/resolve.js:141:11)
    at Observable.rxjs_1.Observable [as _subscribe] (/home/Projects/myProjectName/node_modules/@angular-devkit/architect/src/architect.js:132:40)

<代码>ng Update 系指一切符合规定。 Deleting the node_modules <代码>npm 安装 装置也无济于事。

我的项目以ng2-admin(Angular 4 edition)为基础。 这里是我的。 受扶养人:

 "dependencies": {
    "@angular/animations": "^6.0.1",
    "@angular/common": "^6.0.1",
    "@angular/compiler": "^6.0.1",
    "@angular/core": "^6.0.1",
    "@angular/forms": "^6.0.1",
    "@angular/http": "^6.0.1",
    "@angular/platform-browser": "^6.0.1",
    "@angular/platform-browser-dynamic": "^6.0.1",
    "@angular/platform-server": "^6.0.1",
    "@angular/router": "^6.0.1",
    "@ng-bootstrap/ng-bootstrap": "1.0.0-alpha.26",
    "@ngx-translate/core": "^10.0.1",
    "@ngx-translate/http-loader": "^3.0.1",
    "amcharts3": "github:amcharts/amcharts3",
    "ammap3": "github:amcharts/ammap3",
    "angular-table": "^1.0.4",
    "angular2-csv": "^0.2.5",
    "angular2-datatable": "0.6.0",
    "animate.css": "3.5.2",
    "bootstrap": "4.0.0-alpha.6",
    "bower": "^1.8.4",
    "chart.js": "1.1.1",
    "chartist": "0.10.1",
    "chroma-js": "1.3.3",
    "ckeditor": "4.6.2",
    "core-js": "2.4.1",
    "easy-pie-chart": "2.1.7",
    "font-awesome": "4.7.0",
    "fullcalendar": "3.3.1",
    "google-maps": "3.2.1",
    "ionicons": "2.0.1",
    "jquery": "3.2.1",
    "jquery-slimscroll": "1.3.8",
    "leaflet": "0.7.7",
    "leaflet-map": "0.2.1",
    "lodash": "4.17.4",
    "ng2-ckeditor": "1.1.6",
    "ng2-completer": "^1.6.3",
    "ng2-handsontable": "^2.1.0-rc.3",
    "ng2-slim-loading-bar": "^4.0.0",
    "ng2-smart-table": "^1.0.3",
    "ng2-tree": "2.0.0-alpha.5",
    "ngx-uploader": "4.2.4",
    "normalize.css": "6.0.0",
    "roboto-fontface": "0.7.0",
    "rxjs": "^6.1.0",
    "rxjs-compat": "^6.1.0",
    "zone.js": "0.8.26"
  },
  "devDependencies": {
    "@angular/cli": "^6.0.1",
    "@angular/compiler-cli": "^6.0.1",
    "@types/fullcalendar": "2.7.40",
    "@types/jasmine": "2.5.38",
    "@types/jquery": "2.0.41",
    "@types/jquery.slimscroll": "1.3.30",
    "@types/lodash": "4.14.61",
    "@types/node": "6.0.69",
    "codelyzer": "3.0.1",
    "gh-pages": "0.12.0",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "3.2.0",
    "karma": "1.4.1",
    "karma-chrome-launcher": "2.0.0",
    "karma-cli": "1.0.1",
    "karma-coverage-istanbul-reporter": "0.2.0",
    "karma-jasmine": "1.1.0",
    "karma-jasmine-html-reporter": "0.2.2",
    "npm-run-all": "4.0.2",
    "protractor": "5.1.0",
    "rimraf": "2.6.1",
    "standard-changelog": "1.0.1",
    "stylelint": "7.10.1",
    "ts-node": "2.1.2",
    "tslint": "5.2.0",
    "tslint-eslint-rules": "4.0.0",
    "tslint-language-service": "0.9.6",
    "typescript": "^2.7.2",
    "typogr": "0.6.6",
    "underscore": "1.8.3",
    "wintersmith": "2.2.5",
    "wintersmith-sassy": "1.1.0"
  }

我的angular.json 。 档案:

{
  "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
  "version": 1,
  "newProjectRoot": "projects",
  "projects": {
    "ng2-admin": {
      "root": "",
      "sourceRoot": "src",
      "projectType": "application",
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": {
            "outputPath": "dist",
            "index": "src/index.html",
            "main": "src/main.ts",
            "tsConfig": "src/tsconfig.app.json",
            "polyfills": "src/polyfills.ts",
            "assets": [
              "src/assets",
              "src/favicon.ico"
            ],
            "styles": [
              "node_modules/roboto-fontface/css/roboto/sass/roboto-fontface.scss",
              "node_modules/normalize.css/normalize.css",
              "node_modules/font-awesome/scss/font-awesome.scss",
              "node_modules/ionicons/scss/ionicons.scss",
              "node_modules/bootstrap/scss/bootstrap.scss",
              "node_modules/leaflet/dist/leaflet.css",
              "node_modules/chartist/dist/chartist.css",
              "node_modules/fullcalendar/dist/fullcalendar.css",
              "node_modules/handsontable/dist/handsontable.full.css",
              "node_modules/ng2-slim-loading-bar/style.css",
              "src/app/theme/theme.scss",
              "src/styles.scss"
            ],
            "scripts": [
              "node_modules/jquery/dist/jquery.js",
              "node_modules/easy-pie-chart/dist/jquery.easypiechart.js",
              "node_modules/jquery-slimscroll/jquery.slimscroll.js",
              "node_modules/tether/dist/js/tether.js",
              "node_modules/bootstrap/dist/js/bootstrap.js",
              "node_modules/handsontable/dist/handsontable.full.js",
              "node_modules/chroma-js/chroma.js"
            ]
          },
          "configurations": {
            "production": {
              "optimization": true,
              "outputHashing": "all",
              "sourceMap": false,
              "extractCss": true,
              "namedChunks": false,
              "aot": true,
              "extractLicenses": true,
              "vendorChunk": false,
              "buildOptimizer": true,
              "fileReplacements": [
                {
                  "replace": "src/environments/environment.ts",
                  "with": "src/environments/environment.prod.ts"
                }
              ]
            }
          }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "ng2-admin:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "ng2-admin:build:production"
            }
          }
        },
        "extract-i18n": {
          "builder": "@angular-devkit/build-angular:extract-i18n",
          "options": {
            "browserTarget": "ng2-admin:build"
          }
        },
        "test": {
          "builder": "@angular-devkit/build-angular:karma",
          "options": {
            "main": "src/test.ts",
            "karmaConfig": "./karma.conf.js",
            "polyfills": "src/polyfills.ts",
            "tsConfig": "src/tsconfig.spec.json",
            "scripts": [
              "node_modules/jquery/dist/jquery.js",
              "node_modules/easy-pie-chart/dist/jquery.easypiechart.js",
              "node_modules/jquery-slimscroll/jquery.slimscroll.js",
              "node_modules/tether/dist/js/tether.js",
              "node_modules/bootstrap/dist/js/bootstrap.js",
              "node_modules/handsontable/dist/handsontable.full.js",
              "node_modules/chroma-js/chroma.js"
            ],
            "styles": [
              "node_modules/roboto-fontface/css/roboto/sass/roboto-fontface.scss",
              "node_modules/normalize.css/normalize.css",
              "node_modules/font-awesome/scss/font-awesome.scss",
              "node_modules/ionicons/scss/ionicons.scss",
              "node_modules/bootstrap/scss/bootstrap.scss",
              "node_modules/leaflet/dist/leaflet.css",
              "node_modules/chartist/dist/chartist.css",
              "node_modules/fullcalendar/dist/fullcalendar.css",
              "node_modules/handsontable/dist/handsontable.full.css",
              "node_modules/ng2-slim-loading-bar/style.css",
              "src/app/theme/theme.scss",
              "src/styles.scss"
            ],
            "assets": [
              "src/assets",
              "src/favicon.ico"
            ]
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "src/tsconfig.app.json",
              "src/tsconfig.spec.json"
            ],
            "exclude": []
          }
        }
      }
    },
    "ng2-admin-e2e": {
      "root": "",
      "sourceRoot": "",
      "projectType": "application",
      "architect": {
        "e2e": {
          "builder": "@angular-devkit/build-angular:protractor",
          "options": {
            "protractorConfig": "./protractor.conf.js",
            "devServerTarget": "ng2-admin:serve"
          }
        },
        "lint": {
          "builder": "@angular-devkit/build-angular:tslint",
          "options": {
            "tsConfig": [
              "e2e/tsconfig.e2e.json"
            ],
            "exclude": []
          }
        }
      }
    }
  },
  "defaultProject": "ng2-admin",
  "schematics": {
    "@schematics/angular:component": {
      "prefix": "app",
      "styleext": "scss"
    },
    "@schematics/angular:directive": {
      "prefix": "app"
    }
  }
}
最佳回答

Install @angular-devkit/build-angular as dev Depend. 这套措施新引入Angular 6.0

npm install --save-dev @angular-devkit/build-angular

yarn add @angular-devkit/build-angular --dev
问题回答
npm update

It worked like a charm.

关于安插6和以上,我的工作方法是:

npm install

最终

npm update

我们需要明确接纳发展中国家。

npm i --only=dev

Please follow these five steps. It s definitely worked (my personal experience)

步骤1:

步骤2: www.un.org/Depts/DGACM/index_spanish.htm

第3步:<代码>npm 装置-g @angular/cli@latest

步骤4:npm i

第5步:ng Building

之后,<代码>ng服务。

如果以下指挥人员不工作,

npm install --save-dev @angular-devkit/build-angular

之后,该项目翻了几番,并进行了指挥:

npm install --save @angular-devkit/build-angular

我将地雷定在:

  1. 删除斜体。

以前的所有答复都是正确的,但并非对我工作。 我完成这项工作的唯一途径是:

npm uninstall -g @angular/[email protected]
npm cache clean --force
npm install -g @angular/cli@latest
npm install node-sass -g
ng new MY_PROJECT_NAME
cp -r from_my_old_project to_new_MY_PROJECT_NAME

<Forular 8

Install npm-check-updates package

页: 1

$ npm i npm-check-updates
$ ncu -u
$ npm install

这一一揽子计划将更新所有一揽子计划并解决这一问题。

通知:更新后 如果你面临这一问题:

ERROR in The Angular Compiler requires TypeScript >=3.4.0 and <3.6.0 but 3.6.3 was found instead.

接着:

$ npm install [email protected]

<Link

Just type and run. Then the project will run without errors.

也可使用<代码>npm 安装——save-dev @angular-devkit/build-angular。

引证。

npm install

npm update

如果能显示这样的情况,

页: 1

!

以下是我的工作。 不幸的是,别无他事。

npm uninstall @angular-devkit/build-angular
npm install @angular-devkit/build-angular
ng update --all --allow-dirty --force

以下指挥部门开展工作:

npm install
ng update

你可以看到“我们分析你的包裹......json,似乎一切都符合要求”。 斡旋

npm update

然后尝试发展:

ng build

我将大体字体的错误降为:

npm install typescript@">=3.1.1 <3.2

ng build --prod

生产建设取得的所有成功。

Below is the working combination:

ng --version

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.11.0
@angular-devkit/build-angular     0.11.0
@angular-devkit/build-optimizer   0.11.0
@angular-devkit/build-webpack     0.11.0
@angular-devkit/core              7.1.0
@angular-devkit/schematics        7.1.0
@angular/cli                      7.1.0
@ngtools/webpack                  7.1.0
@schematics/angular               7.1.0
@schematics/update                0.11.0
rxjs                              6.3.3
typescript                        3.1.6
webpack                           4.23.1

解决我的问题:

  1. 删除 页: 1

  2. 页: 1

npm install --save-dev @angular-devkit/build-angular@latest

这对我来说已经解决了。

首先,删除<条码>。 夹

然后Restart system

页: 1 --save-dev @angular-devkit/build-angular

以及

页: 1

使用:

npm i --save-dev @angular-devkit/build-angular

该代码将@angular-devkit/build-angular作为发展依赖。

试验<>为100%。

When we run commands like ng serve, it uses the local version of @angular/cli. So first install the latest version of @angular/cli locally (without the -g flag). Then update the cli using the ng update @angular/cli command. I thing this should fix the issue.

<Angular Update Guide,如果你正在更新你的“安热”项目,可帮助您。

这一错误一般发生在“安热”项目没有完全配置的情况下。

工作

npm install --save-dev @angular-devkit/build-angular

npm install

只是执行以下指挥,错误将解决。

  • ng update @angular/cli @angular/core
  • npm uninstall @angular-devkit/build-angular
  • npm install --save-dev @angular-devkit/build-angular

If this error could not be resolved by the above command, then you update the Node.js version:

npm update npm -g

我有一个图书馆,用老式的安热文制作。

既然我升级为最新版本11,该建筑就会失败。

事实上,建筑商发生了变化。

采用<条码>纳克 我的错误信息有些类似:

Cannot find module  @angular-devkit/build-ng-packagr/package.json 

在<代码>angular.json档案中,我不得不改变建筑商的财产:

"builder": "@angular-devkit/build-ng-packagr:build",

"builder": "@angular-devkit/build-angular:ng-packagr",

第1条

npm install --save-dev @angular-devkit/build-angular

如果遗失包裹再次出现一些错误

npm install

这为我工作,承诺,然后:

ng update @angular/cli @angular/core
npm install --save-dev @angular/cli@latest

所有这些答复基本上都是一样的。

npm install -D @angular-devkit/build-angular
npm install

但是,如果你在“<条码>/平线>项目(如<条码>米-lib)上,在“安热”工作空间内,这仍然可能失败:

workspace
|-- projects
|    |-- my-lib
|        |-- package.json
|
|-- package.json

在这种情况下,确保不仅在名录上操作<代码>npm >,而且直接在workspace/projects/my-lib上操作npmstal>。

我在一分钟前就与同样的问题作斗争。 我的项目是利用1.6.0版的红外电产生的。

  1. <编码>npm Update -g @angular/cli

  2. editing my package.json, changing the line

    "@angular/cli": "1.6.0",
    

    纽约总部

    "@angular/cli": "^1.6.0",
    

I had the same problem today, after upgrading Node.js from v9 to v10.
My environment is set by Docker and I had to remove this command from the my DockerFile:

npm link @angular/cli

It creates a symbolic link to the directory where Node.js is installed.
I guess the angular/cli module in it do not have the same version as the one in the node_modules directory of my project, and this causes the issue.

我面临同样的问题。

简言之,这只是因为<条码>>>> 转具体规定的<条码> 包装.json并非按预期格式。

我从“<条码>转换”改为:“0.1”至<条码>转换”:“0.0.1”,并解决问题。

Angular needs semantic (也读到Semver,有三部分。

我对最新版本<代码>@angular-devkit/build-angular有问题。 (截至撰写本报告时,11.5小时前才获释)。

我们的公司正在使用Nexus 托存管理人作为Npm登记处(我们无法直接查阅https://registry.npmjs.org/“rel=“nofollow noreferer”https://registry.npmjs.org/)。 这一版本是这么新的,但还没有列入我们的Nexus。

Invalidating,cache of the repository and npmstal specified the issue.





相关问题
Angular matSort not working on Date column by desc

Trying to sort the material table with date column , date format is MM/DD/YYYY ,h:mm A , order of date is not by latest date and time. Anything which i missed from the below stackblitz code. https:/...

热门标签