我正在尝试运行Angular项目,但是失败了。尝试在我的项目中运行“ ng serve --open”时,我遇到了以下信息:
** Angular Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
Date: 2018-07-29T18:24:22.347Z
Hash: a1b425038571039765db
Time: 16813ms
chunk {main} main.js, main.js.map (main) 32.8 kB [initial] [rendered]
chunk {polyfills} polyfills.js, polyfills.js.map (polyfills) 227 kB [initial] [rendered]
chunk {runtime} runtime.js, runtime.js.map (runtime) 5.22 kB [entry] [rendered]
chunk {styles} styles.js, styles.js.map (styles) 15.6 kB [initial] [rendered]
chunk {vendor} vendor.js, vendor.js.map (vendor) 6.93 MB [initial] [rendered]
WARNING in ./node_modules/socket.io/lib/index.js
113:11-32 Critical dependency: the request of a dependency is an expression
WARNING in ./node_modules/engine.io/node_modules/ws/lib/BufferUtil.js
Module not found: Error: Can't resolve 'bufferutil' in 'C:\Users\user\Desktop\chat-app\client\node_modules\engine.io\node_modules\ws\lib'
WARNING in ./node_modules/engine.io/node_modules/ws/lib/Validation.js
Module not found: Error: Can't resolve 'utf-8-validate' in 'C:\Users\user\Desktop\chat-app\client\node_modules\engine.io\node_modules\ws\lib'
ERROR in ./node_modules/base64id/lib/base64id.js
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\user\Desktop\chat-app\client\node_modules\base64id\lib'
ERROR in ./node_modules/engine.io/node_modules/ws/lib/Sender.js
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\user\Desktop\chat-app\client\node_modules\engine.io\node_modules\ws\lib'
ERROR in ./node_modules/engine.io/node_modules/ws/lib/WebSocketServer.js
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\user\Desktop\chat-app\client\node_modules\engine.io\node_modules\ws\lib'
ERROR in ./node_modules/engine.io/node_modules/ws/lib/WebSocket.js
Module not found: Error: Can't resolve 'crypto' in 'C:\Users\user\Desktop\chat-app\client\node_modules\engine.io\node_modules\ws\lib'
ERROR in ./node_modules/socket.io/lib/index.js
Module not found: Error: Can't resolve 'fs' in 'C:\Users\user\Desktop\chat-app\client\node_modules\socket.io\lib'
ERROR in ./node_modules/engine.io/lib/engine.io.js
Module not found: Error: Can't resolve 'http' in 'C:\Users\user\Desktop\chat-app\client\node_modules\engine.io\lib'
ERROR in ./node_modules/engine.io/node_modules/ws/lib/WebSocket.js
Module not found: Error: Can't resolve 'http' in 'C:\Users\user\Desktop\chat-app\client\node_modules\engine.io\node_modules\ws\lib'
ERROR in ./node_modules/engine.io/node_modules/ws/lib/WebSocketServer.js
Module not found: Error: Can't resolve 'http' in 'C:\Users\user\Desktop\chat-app\client\node_modules\engine.io\node_modules\ws\lib'
ERROR in ./node_modules/socket.io/lib/index.js
Module not found: Error: Can't resolve 'http' in 'C:\Users\user\Desktop\chat-app\client\node_modules\socket.io\lib'
ERROR in ./node_modules/engine.io/node_modules/ws/lib/WebSocket.js
Module not found: Error: Can't resolve 'https' in 'C:\Users\user\Desktop\chat-app\client\node_modules\engine.io\node_modules\ws\lib'
ERROR in ./node_modules/mime-types/index.js
Module not found: Error: Can't resolve 'path' in 'C:\Users\user\Desktop\chat-app\client\node_modules\mime-types'
ERROR in ./node_modules/socket.io/lib/index.js
Module not found: Error: Can't resolve 'path' in 'C:\Users\user\Desktop\chat-app\client\node_modules\socket.io\lib'
ERROR in ./node_modules/engine.io/lib/server.js
Module not found: Error: Can't resolve 'uws' in 'C:\Users\user\Desktop\chat-app\client\node_modules\engine.io\lib'
ERROR in ./node_modules/engine.io/lib/transports/polling.js
Module not found: Error: Can't resolve 'zlib' in 'C:\Users\user\Desktop\chat-app\client\node_modules\engine.io\lib\transports'
ERROR in ./node_modules/engine.io/node_modules/ws/lib/PerMessageDeflate.js
Module not found: Error: Can't resolve 'zlib' in 'C:\Users\user\Desktop\chat-app\client\node_modules\engine.io\node_modules\ws\lib'
i 「wdm」: Failed to compile.
但是,当我手动进入node_modules中的那些文件时,我确实看到了这些符号。这是我的package.json:
{
"name": "client",
"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.1.0",
"@angular/cdk": "^6.4.1",
"@angular/common": "^6.1.0",
"@angular/compiler": "^6.1.0",
"@angular/core": "^6.1.0",
"@angular/forms": "^6.1.0",
"@angular/http": "^6.1.0",
"@angular/material": "^6.4.1",
"@angular/platform-browser": "^6.1.0",
"@angular/platform-browser-dynamic": "^6.1.0",
"@angular/router": "^6.1.0",
"core-js": "^2.5.4",
"rxjs": "^6.0.0",
"socket.io": "^2.1.1",
"zone.js": "~0.8.26"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.7.0",
"@angular/cli": "~6.1.1",
"@angular/compiler-cli": "^6.1.0",
"@angular/language-service": "^6.1.0",
"@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"
}
}
这些错误是否与SocketIO软件包有关?我试图删除node_modules文件夹并再次安装,但仍然无法正常工作。如何解决此错误?谢谢!
答案 0 :(得分:0)
我从npm切换到yarn,它的效果要好得多,切换起来并不是很难。我是通过在命令行上键入“ yarn”来做到这一点的,但是您最好还是用Google搜索一下,记住它并不难。