我尝试了所有给定的解决方案,例如更新 angular / cli ,甚至卸载并重新安装 node / npm 。我可以创建一个新项目,它可以按预期工作,但是当我尝试在现有项目上运行ng serve命令时,它向我显示以下错误。请帮助解决此问题。
module.js:549 抛出错误; ^
错误:找不到模块“ ./template” 在Function.Module._resolveFilename(module.js:547:15) 在Function.Module._load(module.js:474:25) 在Module.require(module.js:596:17) 在要求时(internal / module.js:11:18) 在对象。 (E:\ Project \ Nitesh \ AngularMergedCode \ AngularDemo \ node_modules \ @ angular-devkit \ core \ src \ utils \ index.js:19:10) 在Module._compile(module.js:652:30) 在Object.Module._extensions..js(module.js:663:10) 在Module.load(module.js:565:32) 在tryModuleLoad(module.js:505:12) 在Function.Module._load(module.js:497:3) PS E:\ Project \ Nitesh \ AngularMergedCode \ AngularDemo> npm更新 PS E:\ Project \ Nitesh \ AngularMergedCode \ AngularDemo> ng服务
Package.json文件:
{
"name": "offica-replica",
"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": {
"@agm/core": "^1.0.0-beta.3",
"@angular-devkit/build-angular": "^0.6.8",
"@angular/animations": "^6.0.9",
"@angular/common": "^6.0.9",
"@angular/compiler": "^6.0.9",
"@angular/core": "^6.0.9",
"@angular/forms": "^6.0.9",
"@angular/http": "^6.0.9",
"@angular/platform-browser": "^6.0.9",
"@angular/platform-browser-dynamic": "^6.0.9",
"@angular/router": "^6.0.9",
"core-js": "^2.5.4",
"ngx-infinite-scroll": "^6.0.1",
"ngx-pagination": "^3.1.1",
"ngx-spinner": "^6.0.0",
"ngx-toastr": "^8.9.1",
"rxjs": "^6.2.2",
"rxjs-compat": "^6.2.2",
"template": "^0.17.5",
"zone.js": "^0.8.26"
},
"devDependencies": {
"@angular/cli": "^6.0.8",
"@angular/compiler-cli": "^6.0.9",
"@angular/language-service": "^6.0.9",
"@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",
"typescript": "~2.7.2"
}
}
答案 0 :(得分:0)
I resolved this problem, It was a missing module problem so i need to perform these 2 steps:
1.Remove node_modules folder from project directory.
Run command npm install (This will reinstall all missing modules)
After this ng serve command works fine.