reqwest icon indicating copy to clipboard operation
reqwest copied to clipboard

Cannot resolve module 'xhr2'

Open fskinner opened this issue 10 years ago • 15 comments

I'm getting this error everytime i run my webpack bundle. I've installed reqwest via npm

Module not found: Error: Cannot resolve module 'xhr2' in c:\Users\xxx\Git\xxx\node_modules\reqwest

fskinner avatar Aug 04 '15 15:08 fskinner

are you intending to use this in Node.js or the Browser?

ded avatar Aug 04 '15 15:08 ded

One solution is to simply install xhr2 — it's noted a peerDependency (meaning, you have to install it yourself). That is, if you're using it in Node.js.

Otherwise, I'm not entirely clear how WebPack Bundles libraries. I could add a try {} catch () to mitigate the issue. The fact of the matter is xhr2 is not an actual dependency if you're running it in the browser, so it's best left out as a real dependency in the package.json file

ded avatar Aug 04 '15 15:08 ded

I'm using on the browser. I will add it on my dependencies then! But it would be better not to depend on it, since I'm on the browser... And not showing that annoying warning :(

fskinner avatar Aug 04 '15 18:08 fskinner

yes indeed. i will get a fix out for this shortly

ded avatar Aug 04 '15 18:08 ded

Seconding this. While reqwest works fine in-browser with the warning, it will save many a moment of panic to handle it better.

veddermatic avatar Aug 15 '15 16:08 veddermatic

@fskinner +1

afc163 avatar Aug 27 '15 13:08 afc163

+1

jzumbrun avatar Aug 29 '15 14:08 jzumbrun

hey all! this has been resolved thanks to a workaround found in a recent pull-request. you should be good to go now. it will no longer blow up in the browser

ded avatar Sep 02 '15 23:09 ded

great to hear!

fskinner avatar Sep 03 '15 00:09 fskinner

2.0.3 broke my build, webpack output below. I reverted to 1.1.6 to get rid of the xhr2 message, haven't had any problems with it yet.

WARNING in ./~/reqwest/reqwest.js Critical dependencies: 24:13-26 the request of a dependency is an expression @ ./~/reqwest/reqwest.js 24:13-26

WARNING in ./~/reqwest/package.json Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/package.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "name": "reqwest", | "description": "A wrapper for asynchronous http requests", | "keywords": [ @ ./~/reqwest ^./.*$

WARNING in ./~/reqwest/Makefile Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/Makefile Line 1: Unexpected token . You may need an appropriate loader to handle this file type. | .PHONY: boosh test | | boosh: @ ./~/reqwest ^./.*$

WARNING in ./~/reqwest/README.md Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/README.md Line 1: Unexpected token ILLEGAL You may need an appropriate loader to handle this file type. | # It's AJAX | | All over again. Includes support for xmlHttpRequest, JSONP, CORS, and CommonJS Promises A. @ ./~/reqwest ^./.*$

WARNING in ./~/reqwest/build.json Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/build.json Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "YO": "This file is built by the Makefile, your edits may not be saved on build", | "JAVASCRIPT": { | "DIST_DIR": "./", @ ./~/reqwest ^./.*$

WARNING in ./~/reqwest/reqwest.min.js Critical dependencies: 6:6599-6612 the request of a dependency is an expression @ ./~/reqwest/reqwest.min.js 6:6599-6612

WARNING in ./~/reqwest/src/reqwest.js Critical dependencies: 18:13-26 the request of a dependency is an expression @ ./~/reqwest/src/reqwest.js 18:13-26

WARNING in ./~/reqwest/tests/fixtures/badfixtures.xml Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/tests/fixtures/badfixtures.xml Line 1: Unexpected token > You may need an appropriate loader to handle this file type. | ><><>Not a valid xml document<><>< @ ./~/reqwest ^./.*$

WARNING in ./~/reqwest/tests/fixtures/fixtures.html Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/tests/fixtures/fixtures.html Line 1: Unexpected token < You may need an appropriate loader to handle this file type. |

boosh

@ ./~/reqwest ^./.*$

WARNING in ./~/reqwest/tests/fixtures/fixtures.json Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/tests/fixtures/fixtures.json Line 1: Unexpected token : You may need an appropriate loader to handle this file type. | { "boosh": "boosh" } @ ./~/reqwest ^./.*$

WARNING in ./~/reqwest/tests/fixtures/fixtures.xml Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/tests/fixtures/fixtures.xml Line 1: Unexpected token < You may need an appropriate loader to handle this file type. | boosh @ ./~/reqwest ^./.*$

WARNING in ./~/reqwest/tests/fixtures/fixtures_with_prefix.json Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/tests/fixtures/fixtures_with_prefix.json Line 1: Unexpected token ] You may need an appropriate loader to handle this file type. | ])}while(1);{ "boosh": "boosh" } @ ./~/reqwest ^./.*$

WARNING in ./~/reqwest/tests/fixtures/invalidJSON.json Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/tests/fixtures/invalidJSON.json Line 1: Unexpected identifier You may need an appropriate loader to handle this file type. | this is not valid JSON!, there: are ~!_+ punctuation | | marks @ ./~/reqwest ^./.*$

WARNING in ./~/reqwest/tests/tests.html Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/tests/tests.html Line 1: Unexpected token < You may need an appropriate loader to handle this file type. | | |

@ ./~/reqwest ^./.*$

WARNING in ./~/reqwest/use-me.sublime-project Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/use-me.sublime-project Line 2: Unexpected token : You may need an appropriate loader to handle this file type. | { | "folders": [{ | "path": ".", | "folder_exclude_patterns": [ @ ./~/reqwest ^./.*$

WARNING in ./~/reqwest/vendor/phantomjs Module parse failed: /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/vendor/phantomjs Line 1: Unexpected token ILLEGAL You may need an appropriate loader to handle this file type. (Source code omitted for this binary file) @ ./~/reqwest ^./.*$

ERROR in ./~/reqwest/make/bump.js Module not found: Error: Cannot resolve module 'fs' in /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/make @ ./~/reqwest/make/bump.js 1:9-22

ERROR in ./~/reqwest/make/tests.js Module not found: Error: Cannot resolve module 'fs' in /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/make @ ./~/reqwest/make/tests.js 2:9-22

ERROR in ./~/reqwest/make/tests.js Module not found: Error: Cannot resolve module 'dispatch' in /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/make @ ./~/reqwest/make/tests.js 4:15-34

ERROR in ./~/reqwest/make/tests.js Module not found: Error: Cannot resolve module 'child_process' in /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/make @ ./~/reqwest/make/tests.js 1:11-35

ERROR in ./~/reqwest/test.js Module not found: Error: Cannot resolve module 'child_process' in /Users/philharton/culturelab/culturelab-web/node_modules/reqwest @ ./~/reqwest/test.js 1:12-36

ERROR in ./~/reqwest/make/tests.js Module not found: Error: Cannot resolve module 'connect' in /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/make @ ./~/reqwest/make/tests.js 3:14-32

ERROR in ./~/reqwest/make/tests.js Module not found: Error: Cannot resolve module 'mime' in /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/make @ ./~/reqwest/make/tests.js 5:11-26

ERROR in ./~/reqwest/make/tests.js Module not found: Error: Cannot resolve module 'delayed-stream' in /Users/philharton/culturelab/culturelab-web/node_modules/reqwest/make @ ./~/reqwest/make/tests.js 6:20-45

ERROR in ./~/reqwest/phantom.js Module not found: Error: Cannot resolve module 'webpage' in /Users/philharton/culturelab/culturelab-web/node_modules/reqwest @ ./~/reqwest/phantom.js 1:11-29

philharton avatar Sep 03 '15 03:09 philharton

I have the same problem occurred. I fix it only to downgrade to 2.0.1

serslon avatar Sep 03 '15 15:09 serslon

Yep, having the same issue

christla avatar Sep 14 '15 21:09 christla

+1. I reverted to 1.1.5 to fix this problem.

dopeboy avatar Sep 15 '15 16:09 dopeboy

well damn. will need to think another solution. this was exactly my reservations to begin with (trying to make this library "isomorphic").

in the meantime looks like a few folks were able to successfully revert.

ded avatar Sep 15 '15 19:09 ded

2.0.2 and 2.0.4 both broke my build, reverting to 2.0.1 fixed it. My errors, to help those coming via search engines:

WARNING in ./~/reqwest/reqwest.js
Critical dependencies:
24:13-26 the request of a dependency is an expression
 @ ./~/reqwest/reqwest.js 24:13-26

WARNING in ./~/reqwest/Makefile
Module parse failed: /Users/timmstokke/work/gotdone-native-app/node_modules/reqwest/Makefile Line 1: Unexpected token .
You may need an appropriate loader to handle this file type.
| .PHONY: boosh test
| 
| boosh:
 @ ./~/reqwest ^\.\/.*$

WARNING in ./~/reqwest/reqwest.min.js
Critical dependencies:
6:6599-6612 the request of a dependency is an expression
 @ ./~/reqwest/reqwest.min.js 6:6599-6612

WARNING in ./~/reqwest/src/reqwest.js
Critical dependencies:
18:13-26 the request of a dependency is an expression
 @ ./~/reqwest/src/reqwest.js 18:13-26

WARNING in ./~/reqwest/tests/fixtures/badfixtures.xml
Module parse failed: /Users/timmstokke/work/gotdone-native-app/node_modules/reqwest/tests/fixtures/badfixtures.xml Line 1: Unexpected token >
You may need an appropriate loader to handle this file type.
| ><><>Not a valid xml document<><><
 @ ./~/reqwest ^\.\/.*$

WARNING in ./~/reqwest/tests/fixtures/fixtures.xml
Module parse failed: /Users/timmstokke/work/gotdone-native-app/node_modules/reqwest/tests/fixtures/fixtures.xml Line 1: Unexpected token <
You may need an appropriate loader to handle this file type.
| <root><boosh>boosh</boosh></root>
 @ ./~/reqwest ^\.\/.*$

WARNING in ./~/reqwest/use-me.sublime-project
Module parse failed: /Users/timmstokke/work/gotdone-native-app/node_modules/reqwest/use-me.sublime-project Line 2: Unexpected token :
You may need an appropriate loader to handle this file type.
| {
|   "folders": [{
|       "path": ".",
|       "folder_exclude_patterns": [
 @ ./~/reqwest ^\.\/.*$

WARNING in ./~/reqwest/use-me.sublime-workspace
Module parse failed: /Users/timmstokke/work/gotdone-native-app/node_modules/reqwest/use-me.sublime-workspace Line 2: Unexpected token :
You may need an appropriate loader to handle this file type.
| {
|   "auto_complete":
|   {
|       "selected_items":
 @ ./~/reqwest ^\.\/.*$

WARNING in ./~/reqwest/tests/fixtures/fixtures_with_prefix.json
Module build failed: SyntaxError: Unexpected token ]
    at Object.parse (native)
    at Object.module.exports (/Users/timmstokke/work/gotdone-native-app/node_modules/json-loader/index.js:7:48)
 @ ./~/reqwest ^\.\/.*$

WARNING in ./~/reqwest/tests/fixtures/invalidJSON.json
Module build failed: SyntaxError: Unexpected token h
    at Object.parse (native)
    at Object.module.exports (/Users/timmstokke/work/gotdone-native-app/node_modules/json-loader/index.js:7:48)
 @ ./~/reqwest ^\.\/.*$

ERROR in ./~/reqwest/make/tests.js
Module not found: Error: Cannot resolve module 'connect' in /Users/timmstokke/work/gotdone-native-app/node_modules/reqwest/make
 @ ./~/reqwest/make/tests.js 3:14-32

ERROR in ./~/reqwest/make/tests.js
Module not found: Error: Cannot resolve module 'dispatch' in /Users/timmstokke/work/gotdone-native-app/node_modules/reqwest/make
 @ ./~/reqwest/make/tests.js 4:15-34

ERROR in ./~/reqwest/make/tests.js
Module not found: Error: Cannot resolve module 'mime' in /Users/timmstokke/work/gotdone-native-app/node_modules/reqwest/make
 @ ./~/reqwest/make/tests.js 5:11-26

ERROR in ./~/reqwest/make/tests.js
Module not found: Error: Cannot resolve module 'delayed-stream' in /Users/timmstokke/work/gotdone-native-app/node_modules/reqwest/make
 @ ./~/reqwest/make/tests.js 6:20-45

ERROR in ./~/reqwest/phantom.js
Module not found: Error: Cannot resolve module 'webpage' in /Users/timmstokke/work/gotdone-native-app/node_modules/reqwest
 @ ./~/reqwest/phantom.js 1:11-29

t1mmen avatar Oct 03 '15 22:10 t1mmen