Skip to content
This repository has been archived by the owner on May 11, 2021. It is now read-only.

Browserify : Cannot find module #11

Closed
ghost opened this issue Jul 17, 2017 · 4 comments
Closed

Browserify : Cannot find module #11

ghost opened this issue Jul 17, 2017 · 4 comments
Assignees
Labels

Comments

@ghost
Copy link

ghost commented Jul 17, 2017

Hello,

I'm rather new to front-end development. I'm trying to setup a Typescript project and rx-http-request seems to be the perfect package for HTTP requests.
Unfortunately, I can't manage to make it work with browserify, I always get errors about a module not found in the rx-http-request package.

Here is how to reproduce it:

tree

test-project
├───gulpfile.babel.js
├───main.ts
├───package.json
└───tsconfig.json

gulpfile.babel.js

const gulp = require("gulp");
const browserify = require("browserify");
const source = require('vinyl-source-stream');
const tsify = require("tsify");

gulp.task("default", function () {
    return browserify({
        basedir: '.',
        debug: true,
        entries: ['main.ts'],
        cache: {},
        packageCache: {}
    })
        .plugin(tsify)
        .bundle()
        .pipe(source('bundle.js'))
        .pipe(gulp.dest("build"));
});

main.ts

import {RxHR} from "@akanass/rx-http-request";

RxHR.get('http://www.google.fr').subscribe(
    (data) => {

        if (data.response.statusCode === 200) {
            console.log(data.body);
        }
    },
    (err) => console.error(err)
);

package.json

{
  "name": "Test",
  "version": "1.0.0",
  "description": "Test",
  "private": true,
  "scripts": {
    "build": "gulp"
  },
  "dependencies": {
    "@akanass/rx-http-request": "2.4.0",
    "rxjs": "5.4.2"
  },
  "devDependencies": {
    "babel-core": " 6.25.0",
    "browserify": "14.4.0",
    "gulp": "3.9.1",
    "tsify": "3.0.1",
    "typescript": "2.4.1",
    "vinyl-source-stream": "1.1.0"
  }
}

tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "target": "es2015",
    "noImplicitAny": true,
    "skipLibCheck": true,
    "sourceMap": true,
    "experimentalDecorators": true,
    "emitDecoratorMetadata": true,
    "lib": [
      "es6",
      "DOM"
    ]
  }
}

Reproduction sequence

npm install
npm run build

Error

Error: Cannot find module './RxCookieJar' from 'E:\code\test-project\node_modules\@akanass\rx-http-request'
    at E:\code\test-project\node_modules\browser-resolve\node_modules\resolve\lib\async.js:55:21
    at load (E:\code\test-project\node_modules\browser-resolve\node_modules\resolve\lib\async.js:69:43)
    at onex (E:\code\test-project\node_modules\browser-resolve\node_modules\resolve\lib\async.js:92:31)
    at E:\code\test-project\node_modules\browser-resolve\node_modules\resolve\lib\async.js:22:47
    at FSReqWrap.oncomplete (fs.js:123:15)

Note : it's not always ./RxCookieJar that causes the problem, sometimes it's ./RxHttpRequest, or even ./compile

I suspect it's an error in my tsconfig.json file, but I have no clue what's wrong here, and I hope you'll be able to help me. rx-http-request is so far the only package that causes me trouble, and I really don't want to use another package instead.

Thanks in advance for your help !

@akanass
Copy link
Owner

akanass commented Jul 18, 2017

@Orhleil I'm creating a bundle for you and I'll give you when I've finished

And I found the same error when I want to browserify it so I need to find a solution to create my library's bundle

@akanass akanass added bug and removed question labels Jul 18, 2017
akanass added a commit that referenced this issue Jul 18, 2017
@akanass
Copy link
Owner

akanass commented Jul 18, 2017

@Orhleil fix is done and problem went from entry browser in package.json because it's a standalone version.

New version published and documentation for standalone browser version updated

Now, bundle can work without problem and you must install latest version v2.5.0 like this:

$ npm install --save @akanass/rx-http-request rxjs

Sorry for the delay and the mistake.

@akanass akanass closed this as completed Jul 18, 2017
@ghost
Copy link
Author

ghost commented Jul 18, 2017

It took you almost exactly 12 hours to take charge of the ticket, try it out, confirm it, search a solution, implement it, commit it, publish it and close the ticket.

Sorry for the delay

Are you serious ?? What you call "delay" I call "premium support" 😄 I wish many other projects were as reactive as you are.
Thanks a lot for the quick answer and the fix. I'll give you a star for the great library and the excellent support.
Have a nice day !

@akanass
Copy link
Owner

akanass commented Jul 18, 2017

@Orhleil it was a pleasure and I'm contributing a new node framework and I think you can love it :) don't hesitate to share, like and speak about it 👍

https://github.com/hapinessjs/hapiness

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

1 participant