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

Browserify : Cannot find module #11

@ghost

Description

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 !

Metadata

Metadata

Assignees

Labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions