找不到模块:错误:无法解析'crypto'
当我运行ng serve
时,我得到以下错误列表。
我的包JSON如下:
{ "name": "ProName", "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-devkit/build-angular": "~0.12.0",
"@angular/animations": "5.2.10",
"@angular/common": "5.2.10",
"@angular/compiler": "5.2.10",
"@angular/compiler-cli": "5.2.10",
"@angular/core": "5.2.10",
"@angular/forms": "5.2.10",
"@angular/platform-browser": "5.2.10",
"@angular/platform-browser-dynamic": "5.2.10",
"@angular/router": "5.2.10",
"@types/dotenv": "^4.0.3",
"@types/errorhandler": "0.0.32",
"@types/express": "^4.16.0",
"@types/node": "^10.5.1",
"apostille-library": "^7.1.0",
"core-js": "^2.5.4",
"dotenv": "^6.0.0",
"errorhandler": "^1.5.0",
"express": "^4.16.0",
"nem2-sdk": "^0.9.7",
"rxjs": "~6.3.3",
"stream": "0.0.2",
"tslib": "^1.9.0",
"typescript": "^2.9.2",
"zone.js": "~0.8.26" } }
我得到的错误:
回答如下:./node_modules/aws-sign2/index.js中的错误找不到模块:错误:无法解析./node_modules中'/ Users / MYPC / Documents / Myproj / ProName / node_modules / aws-sign2'错误中的'crypto' /aws4/aws4.js找不到模块:错误:无法解析./node_modules/ecc-jsbn/index.js中'/ Users / MYPC / Documents / Myproj / ProName / node_modules / aws4'错误中的'crypto'模块找不到:错误:无法解析'/ Users / MYPC / Documents / Myproj / ProName / node_modules / ecc-jsbn'中的'crypto'错误./node_modules/http-signature/lib/verify.js找不到模块:错误:无法解决'/ Users / MYPC / Documents / Myproj / ProName / node_modules / http-signature / lib'中的'crypto'错误./node_modules/http-signature/lib/signer.js找不到模块:错误:无法解决./node_modules/nem-sdk/build/external/nacl-fast.js中'/ Users / MYPC / Documents / Myproj / ProName / node_modules / http-signature / lib'错误中的'crypto'模块发现:错误:无法解决'/ Users / MYPC / Documents / Myproj / ProName / node_modules / nem-sdk / build / external'错误中的'crypto' ./node_modules/nem-sdk/node_modules/aws-sign2/index.js
最近我试图在我正在试验的一个小项目中使用另一个库(tiff.js)时遇到了类似的问题。
我解决这个问题的方法是在devDependencies
部分之后添加以下内容到我的package.json文件中。
"devDependencies": {
...
},
"browser": {
"crypto": false
}
尝试在应用程序中使用库时,这似乎没有任何不利影响。
找不到模块:错误:无法解析'crypto'
当我运行ng serve
时,我得到以下错误列表。
我的包JSON如下:
{ "name": "ProName", "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-devkit/build-angular": "~0.12.0",
"@angular/animations": "5.2.10",
"@angular/common": "5.2.10",
"@angular/compiler": "5.2.10",
"@angular/compiler-cli": "5.2.10",
"@angular/core": "5.2.10",
"@angular/forms": "5.2.10",
"@angular/platform-browser": "5.2.10",
"@angular/platform-browser-dynamic": "5.2.10",
"@angular/router": "5.2.10",
"@types/dotenv": "^4.0.3",
"@types/errorhandler": "0.0.32",
"@types/express": "^4.16.0",
"@types/node": "^10.5.1",
"apostille-library": "^7.1.0",
"core-js": "^2.5.4",
"dotenv": "^6.0.0",
"errorhandler": "^1.5.0",
"express": "^4.16.0",
"nem2-sdk": "^0.9.7",
"rxjs": "~6.3.3",
"stream": "0.0.2",
"tslib": "^1.9.0",
"typescript": "^2.9.2",
"zone.js": "~0.8.26" } }
我得到的错误:
回答如下:./node_modules/aws-sign2/index.js中的错误找不到模块:错误:无法解析./node_modules中'/ Users / MYPC / Documents / Myproj / ProName / node_modules / aws-sign2'错误中的'crypto' /aws4/aws4.js找不到模块:错误:无法解析./node_modules/ecc-jsbn/index.js中'/ Users / MYPC / Documents / Myproj / ProName / node_modules / aws4'错误中的'crypto'模块找不到:错误:无法解析'/ Users / MYPC / Documents / Myproj / ProName / node_modules / ecc-jsbn'中的'crypto'错误./node_modules/http-signature/lib/verify.js找不到模块:错误:无法解决'/ Users / MYPC / Documents / Myproj / ProName / node_modules / http-signature / lib'中的'crypto'错误./node_modules/http-signature/lib/signer.js找不到模块:错误:无法解决./node_modules/nem-sdk/build/external/nacl-fast.js中'/ Users / MYPC / Documents / Myproj / ProName / node_modules / http-signature / lib'错误中的'crypto'模块发现:错误:无法解决'/ Users / MYPC / Documents / Myproj / ProName / node_modules / nem-sdk / build / external'错误中的'crypto' ./node_modules/nem-sdk/node_modules/aws-sign2/index.js
最近我试图在我正在试验的一个小项目中使用另一个库(tiff.js)时遇到了类似的问题。
我解决这个问题的方法是在devDependencies
部分之后添加以下内容到我的package.json文件中。
"devDependencies": {
...
},
"browser": {
"crypto": false
}
尝试在应用程序中使用库时,这似乎没有任何不利影响。