StackOverflow上的所有答案似乎都没有帮助我,也许是因为它们都是指Angular的较旧版本。
我是一个完全的新手,正在尝试启动第一个Angular项目。我做了npm install -g @angular/cli
ng new first-ang
cd first-ang
但是当我执行ng serve
时,它为我提供了“无法从“ D:\ Angular \ ang”中找到模块“ @ angular-devkit / build-angular”。
有关更多详细信息,请参见“ C:\ Users \ Susanna \ AppData \ Local \ Temp \ ng-hjBvo0 \ angular-errors.log”。
错误日志包含以下内容:
[error] Error: Could not find module "@angular-devkit/build-angular" from "D:\\Angular\\ang".
at Object.resolve (C:\Users\Susanna\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\core\node\resolve.js:151:11)
at WorkspaceNodeModulesArchitectHost.resolveBuilder (C:\Users\Susanna\AppData\Roaming\npm\node_modules\@angular\cli\node_modules\@angular-devkit\architect\node\node-modules-architect-host.js:31:40)
at ServeCommand.initialize (C:\Users\Susanna\AppData\Roaming\npm\node_modules\@angular\cli\models\architect-command.js:134:55)
at process._tickCallback (internal/process/next_tick.js:68:7)
at Function.Module.runMain (internal/modules/cjs/loader.js:832:11)
at startup (internal/bootstrap/node.js:283:19)
at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)
这是package.json文件的样子:
{
"name": "ang",
"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": "~8.2.4",
"@angular/common": "~8.2.4",
"@angular/compiler": "~8.2.4",
"@angular/core": "~8.2.4",
"@angular/forms": "~8.2.4",
"@angular/platform-browser": "~8.2.4",
"@angular/platform-browser-dynamic": "~8.2.4",
"@angular/router": "~8.2.4",
"rxjs": "~6.5.3",
"tslib": "^1.10.0",
"zone.js": "~0.10.2"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.803.3",
"@angular/cli": "~8.3.3",
"@angular/compiler-cli": "~8.2.4",
"@angular/language-service": "~8.2.4",
"@types/node": "~12.7.4",
"@types/jasmine": "~3.4.0",
"@types/jasminewd2": "~2.0.3",
"codelyzer": "^5.0.0",
"jasmine-core": "~3.4.0",
"jasmine-spec-reporter": "~4.2.1",
"karma": "~4.3.0",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~2.1.0",
"karma-jasmine": "~2.0.1",
"karma-jasmine-html-reporter": "^1.4.0",
"protractor": "~5.4.0",
"ts-node": "~8.3.0",
"tslint": "~5.20.0",
"typescript": "~3.6.2"
}
}
我已经尝试更新npm并执行Stackoverlfow上已列出的几乎所有内容,但无济于事。有谁知道如何处理最新版本的Angular?
(链接到我已经尝试过的解决方案: Could not find module "@angular-devkit/build-angular" Could not find module "@angular-devkit/build-angular" with ng serve ng serve is not working after Angular 8 update )
PS:我注意到我的package.json文件没有“ angular-cli”依赖性。这有问题吗?
答案 0 :(得分:1)
在具有packages.json的文件夹中运行X:\
,以便还原所有必需的软件包。 (不是npm install
)