使用节点v8.11.3和npm v6.4.0创建了一个香草Angular2应用,并安装了“ watson-developer-cloud”以使用发现服务。
在ng build --prod
上,以下声明
var DiscoveryV1 = require('watson-developer-cloud/discovery/v1');
引发以下错误:
ERROR in ./node_modules/aws-sign2/index.js
Module not found: Error: Can't resolve 'crypto' in '/Users/gbmmobility/Documents/MobileProjects/gbm-search/node_modules/aws-sign2'
ERROR in ./node_modules/aws4/aws4.js
Module not found: Error: Can't resolve 'crypto' in '/Users/gbmmobility/Documents/MobileProjects/gbm-search/node_modules/aws4'
ERROR in ./node_modules/ecc-jsbn/index.js
Module not found: Error: Can't resolve 'crypto' in '/Users/gbmmobility/Documents/MobileProjects/gbm-search/node_modules/ecc-jsbn'
--- Edited
ERROR in ./node_modules/forever-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/Users/gbmmobility/Documents/MobileProjects/gbm-search/node_modules/forever-agent'
ERROR in ./node_modules/tunnel-agent/index.js
Module not found: Error: Can't resolve 'tls' in '/Users/gbmmobility/Documents/MobileProjects/gbm-search/node_modules/tunnel-agent'
ERROR in ./node_modules/watson-developer-cloud/node_modules/request/request.js
Module not found: Error: Can't resolve 'zlib' in '/Users/gbmmobility/Documents/MobileProjects/gbm-search/node_modules/watson-developer-cloud/node_modules/request'
发现有些人遇到了同样的问题Can't resolve node-modules,但那里没有给出解决方案。
请帮助。谢谢。