request-promise不能被webpacked

所以我试图在客户端使用request-promise,并尝试使用webpack打包,但由于某些文件模块fs ,它不能打包到客户端。 有没有人偶然发现同样的问题并解决?

这是编译输出

 ERROR in ./~/request-promise/~/request/lib/har.js Module not found: Error: Cannot resolve module 'fs' in /node_modules/request-promise/node_modules/request/lib @ ./~/request-promise/~/request/lib/har.js 3:9-22 ERROR in ./~/request-promise/~/request/~/forever-agent/index.js Module not found: Error: Cannot resolve module 'net' in /node_modules/request-promise/node_modules/request/node_modules/forever-agent @ ./~/request-promise/~/request/~/forever-agent/index.js 6:10-24 ERROR in ./~/request-promise/~/request/~/forever-agent/index.js Module not found: Error: Cannot resolve module 'tls' in /node_modules/request-promise/node_modules/request/node_modules/forever-agent @ ./~/request-promise/~/request/~/forever-agent/index.js 7:10-24 ERROR in ./~/request-promise/~/request/~/tough-cookie/lib/cookie.js Module not found: Error: Cannot resolve module 'net' in /node_modules/request-promise/node_modules/request/node_modules/tough-cookie/lib @ ./~/request-promise/~/request/~/tough-cookie/lib/cookie.js 32:10-24 ERROR in ./~/request-promise/~/request/~/tough-cookie/package.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/tough-cookie/package.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "author": { | "name": "Jeremy Stashewsky", | "email": "jstashewsky@salesforce.com" @ ./~/request-promise/~/request/~/tough-cookie/lib/cookie.js 38:14-40 ERROR in ./~/request-promise/~/request/~/tunnel-agent/index.js Module not found: Error: Cannot resolve module 'net' in /node_modules/request-promise/node_modules/request/node_modules/tunnel-agent @ ./~/request-promise/~/request/~/tunnel-agent/index.js 3:10-24 ERROR in ./~/request-promise/~/request/~/tunnel-agent/index.js Module not found: Error: Cannot resolve module 'tls' in /node_modules/request-promise/node_modules/request/node_modules/tunnel-agent @ ./~/request-promise/~/request/~/tunnel-agent/index.js 4:10-24 ERROR in ./~/request-promise/~/request/~/mime-types/~/mime-db/db.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/mime-types/node_modules/mime-db/db.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "application/1d-interleaved-parityfec": { | "source": "iana" | }, @ ./~/request-promise/~/request/~/mime-types/~/mime-db/index.js 11:17-37 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/cache.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/cache.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "properties": { | "beforeRequest": { | "$ref": "#cacheEntry" @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 4:9-32 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/cacheEntry.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/cacheEntry.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "oneOf": [{ | "type": "object", | "optional": true, @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 5:14-42 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/har.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/har.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "type": "object", | "required": [ | "log" @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 10:7-28 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/creator.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/creator.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "type": "object", | "required": [ | "name", @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 8:11-36 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/content.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/content.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "type": "object", | "required": [ | "size", @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 6:11-36 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/cookie.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/cookie.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "type": "object", | "required": [ | "name", @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 7:10-34 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/page.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/page.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "type": "object", | "optional": true, | "required": [ @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 12:8-30 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/pageTimings.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/pageTimings.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "type": "object", | "properties": { | "onContentLoad": { @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 13:15-44 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/request.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/request.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "type": "object", | "required": [ | "method", @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 16:11-36 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/entry.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/entry.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "type": "object", | "optional": true, | "required": [ @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 9:9-32 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/log.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/log.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "type": "object", | "required": [ | "version", @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 11:7-28 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/record.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/record.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "type": "object", | "required": [ | "name", @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 15:10-34 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/postData.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/postData.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "type": "object", | "optional": true, | "required": [ @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 14:12-38 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/timings.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/timings.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "required": [ | "send", | "wait", @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 18:11-36 ERROR in ./~/request-promise/~/request/~/har-validator/lib/schemas/response.json Module parse failed: /node_modules/request-promise/node_modules/request/node_modules/har-validator/lib/schemas/response.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "type": "object", | "required": [ | "status", @ ./~/request-promise/~/request/~/har-validator/lib/schemas/index.js 17:12-38