[英]Cannot read property 'write' of undefined - Angular
I am working on an Angular 5
project where I'm facing issue Cannot read property 'write' of undefined
while trying to build and run( ng serve
):我正在处理一个
Angular 5
项目,我遇到问题Cannot read property 'write' of undefined
( ng serve
):
My local @angular/cli version is 1.7.4
and below are the versions of global @angular/cli, nodejs and npm
:我
local @angular/cli version is 1.7.4
,以下是global @angular/cli, nodejs and npm
的版本:
Angular CLI: 14.2.1
Node: 14.17.3
Package Manager: npm 6.14.17
OS: win32 x64
Angular:
...
Package Version
------------------------------------------------------
@angular-devkit/architect 0.1402.1 (cli-only)
@angular-devkit/core 14.2.1 (cli-only)
@angular-devkit/schematics 14.2.1 (cli-only)
@schematics/angular 14.2.1 (cli-only)
Below is my package.json
file:下面是我的
package.json
文件:
{
"name": "my-app",
"version": "0.0.0",
"license": "Test",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build --prod --build-optimizer=false",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/animations": "^5.0.0",
"@angular/cdk": "^9.1.0",
"@angular/common": "^5.0.0",
"@angular/compiler": "^5.0.0",
"@angular/core": "^5.0.0",
"@angular/forms": "^5.0.0",
"@angular/http": "^5.0.0",
"@angular/platform-browser": "^5.0.0",
"@angular/platform-browser-dynamic": "^5.0.0",
"@angular/router": "^5.0.0",
"@microsoft/microsoft-graph-client": "^1.0.0",
"@microsoft/microsoft-graph-types": "^1.2.0",
"@progress/kendo-theme-default": "^2.47.0",
"@tinymce/tinymce-angular": "^2.0.0",
"@types/jspdf": "^1.1.31",
"adal-angular": "^1.0.17",
"adal-angular-ts": "^1.1.6",
"adal-angular5": "^1.0.36",
"angular-2-local-storage": "^1.0.1",
"angular-checklist": "^1.2.3",
"angular-d3-charts": "^5.0.0",
"angular-localstorage": "^1.1.5",
"angular-sortablejs": "^2.6.0",
"angular2-multiselect-dropdown": "^2.3.0",
"angular2-tinymce": "^2.1.2",
"angular2-toaster": "^4.0.1",
"angular4": "^1.0.0",
"chart.js": "^2.7.2",
"core-js": "^2.4.1",
"css-loader": "^0.28.8",
"es6-promise": "^4.2.5",
"expose-loader": "^0.7.5",
"file-saver": "^1.3.8",
"font-awesome": "^4.7.0",
"hellojs": "^1.16.1",
"html2pdf": "0.0.11",
"html2pdf.js": "^0.9.1",
"jspdf": "^1.5.3",
"jspdf-autotable": "^2.3.2",
"loader": "^2.1.1",
"moment": "^2.22.1",
"ng-multiselect-dropdown": "^0.1.2",
"ng2-bootstrap-modal": "https://github.com/Sky4CE/ng2-bootstrap-modal/tarball/v.1.0.2",
"ng2-drag-drop": "^3.0.2",
"ng2-toastr": "^4.1.2",
"ng2-trim-directive": "^2.1.7",
"ng2cli": "^3.0.0",
"ngx-charts": "^3.0.2",
"ngx-device-detector": "^1.4.0",
"ngx-tabs": "0.0.13",
"ngx-toastr": "^8.4.0",
"node-sass": "^4.13.1",
"pdfmake": "^0.1.36",
"powerbi-client": "^2.6.5",
"primeicons": "^1.0.0-beta.10",
"primeng": "^6.1.7",
"quill": "^1.3.5",
"request-options": "^2.0.0",
"rxjs": "^5.5.2",
"sortablejs": "^1.8.1",
"toastr": "^2.1.4",
"toggle": "^1.0.1",
"upgrade-angular": "^0.1.3",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "^1.7.1",
"@angular/compiler-cli": "^5.0.0",
"@angular/language-service": "^5.0.0",
"@types/adal": "^1.0.29",
"@types/jasmine": "~2.5.53",
"@types/jasminewd2": "~2.0.2",
"@types/node": "~6.0.60",
"@types/quill": "^1.3.7",
"@types/tinymce": "^4.5.16",
"codelyzer": "^4.0.1",
"jasmine-core": "~2.6.2",
"jasmine-spec-reporter": "~4.1.0",
"jwt-decode": "^2.2.0",
"karma": "~1.7.0",
"karma-chrome-launcher": "~2.1.1",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^1.2.1",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"protractor": "~5.1.2",
"ts-node": "~3.2.0",
"tslint": "~5.7.0",
"typescript": "~2.4.2"
}
}
Note that a similar issue was raised earlier also Angular CLI error Cannot read property 'write' of undefined but this fix only applies to a specific version which I unfortunately can't use.请注意,之前也提出了类似的问题Angular CLI 错误无法读取未定义的属性“写入”,但此修复仅适用于我不幸无法使用的特定版本。
I've tried uninstalling @angular/cli
globally, running command npm cache clean --force
to clean the npm cache
(although the command showed me only a warning npm WARN using --force I sure hope you know what you are doing.
and no output as such) and then again installing the latest version of @angular/cli
globally( npm install -g @angular/cli@latest
), deleting node modules
folder and re-installing them( npm install
) but nothing worked.我已经尝试全局卸载
@angular/cli
,运行命令npm cache clean --force
来清理npm cache
(尽管该命令只向我显示警告npm WARN using --force I sure hope you know what you are doing.
没有 output 这样),然后再次全局安装最新版本的@angular/cli
( npm install -g @angular/cli@latest
),删除node modules
文件夹并重新安装它们( npm install
)但没有任何效果。445DF4129安装)6726
I would highly appreciate any help whatsoever about this, thanks.我将非常感谢任何有关此的帮助,谢谢。
Issue is due to version differences between global and local versions of @angular/cli
Please sync up the versions, else you can run the below command问题是由于
@angular/cli
的全局和本地版本之间的版本差异请同步版本,否则您可以运行以下命令
npx run start
npx 运行开始
above line will run only the local version of angular cli which run without any errors!上面的行将只运行 angular cli 的本地版本,它运行没有任何错误!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.