当我运行以下命令时,我得到了以下错误列表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中出错_找不到模块/aws-sign2/index.js模块:错误:无法在'/Users/MYPC/Documents/Myproj/ProName/node中解析'crypto‘_./node中的modules/aws-sign2‘错误_模块/aws4/aws4.js找不到模块:错误:无法在'/Users/MYPC/Documents/Myproj/ProName/node‘中解析'crypto’_模块/aws4‘./node中的错误_找不到模块/ecc-jsbn/index.js模块:错误:无法在'/Users/MYPC/Documents/Myproj/ProName/node中解析'crypto‘_./node中的modules/ecc-jsbn‘错误_找不到Module /http-signature/lib/verify.js模块:错误:无法在'/Users/MYPC/Documents/Myproj/ProName/node‘中解析'crypto’_modules/http-node/lib‘./node中的错误_未找到Module /http-signature/lib/signer.js模块:错误:无法在/Users/MYPC/Documents/Myproj/ProName/node中解析'crypto‘_modules/http-node/lib‘./node中的错误_找不到Module /nem-sdk/build/external/nacl-nacl.js模块:错误:无法在/Users/MYPC/Documents/Myproj/ProName/node中解析'crypto‘_./node中的modules/nem-sdk/build/external‘错误_modules/nem-sdk/node_modules/aws-sign2/index.js
发布于 2019-01-13 02:05:58
我最近在尝试使用另一个库时遇到了类似的问题(tiff.js)在我正在试验的一个小项目中。
我解决这个问题的方法是将以下代码添加到我的package.json文件,紧跟在devDependencies
部分。
"devDependencies": {
...
},
"browser": {
"crypto": false
}
当尝试在应用程序中使用该库时,这似乎没有任何负面影响。
发布于 2020-07-08 04:40:17
在中添加此设置tsconfig.ts项目下的文件解决此警告
"compilerOptions": {
"baseUrl": "./",
"paths": {
"crypto": [
"../../node_modules/crypto-js"
]
}
发布于 2019-03-31 16:29:14
我喜欢R. Richards的答案,但我认为提供一些更多的信息将是有用的。
这是Angular的一个已知问题,Angular CLI开发团队似乎认为这是一个功能,而不是一个bug。中的其他开发人员也是如此。此问题this issue thread,不同意。该线程的贡献者提供了几个变通方法修复,但我的项目没有成功编译,直到我实现了R. Richards的解决方案。不过,我没有恢复之前的更改,所以tacnoman的和GrandSchtroumpf的修复可能对其他人有用。
有些,比如clovis1122这里和问题线程中的其他人质疑为什么web应用程序需要访问这些库,以及为什么不能在服务器端完成必要的任务。我不能代表每个人发言,但我的用例是,在对用户帐户进行身份验证时,Strapi使用必须由客户端解码的JSON Web令牌字符串进行响应。因为必需库取决于crypto
和stream
,您将无法提取JWT过期时间,除非这些依赖项可用。
如果有人在推断R. Richards的答案时遇到困难,您必须将"can't resolve x“错误中显示的所有依赖项设置为false。例如,我的package.json的关键部分是:
"browser": {
"crypto": false,
"stream": false
}
https://stackoverflow.com/questions/54162297
复制相似问题