使用npm,我遵循Angular CLI快速入门页面上的入门指导。
在创建并进入我的新项目“frontend”后,运行<code>ng serve--open<code>,出现以下错误:
Could not find module "@angular-devkit/build-angular" from "C:\\Users\\Brandon\\project-name\\frontend".
Error: Could not find module "@angular-devkit/build-angular" from "C:\\Users\\Brandon\\project-name\\frontend".
at Object.resolve (C:\Users\Brandon\project-name\node_modules\@angular-devkit\core\node\resolve.js:141:11)
at Observable.rxjs_1.Observable [as _subscribe] (C:\Users\Brandon\project-name\node_modules\@angular-devkit\architect\src\architect.js:132:40)
类似的问题
我也删除了模块,清除了缓存,然后安装了一个也没有工作。
package.json:
{
"name": "frontend",
"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.2",
"@angular/common": "^6.0.2",
"@angular/compiler": "^6.0.2",
"@angular/core": "^6.0.2",
"@angular/forms": "^6.0.2",
"@angular/http": "^6.0.2",
"@angular/platform-browser": "^6.0.2",
"@angular/platform-browser-dynamic": "^6.0.2",
"@angular/router": "^6.0.2",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/compiler-cli": "^6.0.2",
"@angular-devkit/build-angular": "~0.6.3",
"typescript": "~2.7.2",
"@angular/cli": "^6.0.3",
"@angular/language-service": "^6.0.2",
"@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": "~1.4.2",
"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"
}
}
angular.json:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"frontend": {
"root": "",
"sourceRoot": "src",
"projectType": "application",
"prefix": "app",
"schematics": {},
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:browser",
"options": {
"outputPath": "dist/frontend",
"index": "src/index.html",
"main": "src/main.ts",
"polyfills": "src/polyfills.ts",
"tsConfig": "src/tsconfig.app.json",
"assets": [
"src/favicon.ico",
"src/assets"
],
"styles": [
"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": "frontend:build"
},
"configurations": {
"production": {
"browserTarget": "frontend:build:production"
}
}
},
"extract-i18n": {
"builder": "@angular-devkit/build-angular:extract-i18n",
"options": {
"browserTarget": "frontend: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/**"
]
}
}
}
},
"frontend-e2e": {
"root": "e2e/",
"projectType": "application",
"architect": {
"e2e": {
"builder": "@angular-devkit/build-angular:protractor",
"options": {
"protractorConfig": "e2e/protractor.conf.js",
"devServerTarget": "frontend:serve"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": "e2e/tsconfig.e2e.json",
"exclude": [
"**/node_modules/**"
]
}
}
}
}
},
"defaultProject": "frontend"
}
如果您使用的是angular版本8,请运行以下命令来修复此问题。
ng update @angular/cli @angular/core
我查看了内部node_modules
显然,只安装了依赖项,而不是 devDependencies。使用新的 NPM,我们需要显式获取 devDependencies:
npm i --only=dev
如果您只想安装 devkit:
npm install @angular-devkit/build-angular
与ken107(github)联合创意
使用npm,我遵循Angular CLI快速入门页面上的入门说明。 角度CLI快速启动 在创建并进入我的新项目“前端”后,运行,出现以下错误: 我试过其他类似问题的建议,但没有效果。答案是运行npm安装--save dev@angular devkit/build angular。 类似问题 我还删除了模块,清除了缓存,然后安装了一个同样不起作用的模块。 package.json: angular
更新到 Angular 6.0.1 后,我在 上收到以下错误: < code>ng update表示一切正常。删除< code>node_modules文件夹和全新的< code>npm安装也没有帮助。 我的项目基于ng2-admin(Angular4版本)。以下是我的package.json dependecies: 和我的angular.json:
我知道这个问题在这里已经有了答案,但是没有一个答案为我解决了这个问题,我仍然得到了堆栈跟踪: 我的全局npm依赖项位于中,但我的项目文件夹和项目依赖项位于中
我在试着更新Angular。因此,我在我用vs-2015创建的Angular项目中从CMD运行,结果在我的项目中得到了另一个错误: 错误TS2345类型“{Imports:typeof BrowserModule[];Declarations:typeof AppComponent[];Bootstrap:typeof AppComp...”得参数不能分配给类型“NGModule”得参数. 类型“
我正在尝试将我的应用部署到 heroku。Heroku本地网络工作完全正常。我尝试过添加npm i @angular-devkit/build-angular,但它没有帮助,我在互联网上也找不到类似的东西。部署到 Heroku 工作正常,直到它到达 ng build --prod 命令,可以在 angular package.json 内的“postinstall”中找到。 package.jso
在运行<code>npm install 然后检查角度版本,构建角度。 --