ded / reqwest

browser asynchronous http requests
2.94k stars 343 forks source link

Cannot resolve module 'xhr2' #204

Open fskinner opened 9 years ago

fskinner commented 9 years ago

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

ded commented 9 years ago

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

ded commented 9 years ago

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

fskinner commented 9 years ago

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 :(

ded commented 9 years ago

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

veddermatic commented 9 years ago

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

afc163 commented 9 years ago

@fskinner +1

jzumbrun commented 9 years ago

+1

ded commented 9 years ago

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

fskinner commented 9 years ago

great to hear!

philharton commented 9 years ago

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. | <!DOCTYPE HTML> | | @ ./~/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

serslon commented 9 years ago

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

christla commented 9 years ago

Yep, having the same issue

dopeboy commented 9 years ago

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

ded commented 9 years ago

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.

t1mmen commented 9 years ago

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