Angular 6 - Module not found: Error: Can't resolve 'http' in

Silagy

I am trying to work with TinCanJS library in angular 6

github project

I installed the package using npm install tincanjs --save

I imported the files in angular.json as follow:

"scripts": [
              "./node_modules/tincanjs/node_modules/xhr2/lib/xhr2.js",
              "./node_modules/tincanjs/build/tincan-min.js"
            ]

I also tried as follow:

"scripts": [
    "./node_modules/xhr2/lib/xhr2.js",
    "./node_modules/tincanjs/build/tincan-min.js"
]

In my app component I imported the tincan library as plain javascript because it has not type script as follow:

import * as TinCan from 'tincanjs';

When I build the project using ng serve I keep getting the following error:

ERROR in ./node_modules/tincanjs/node_modules/xhr2/lib/xhr2.js
Module not found: Error: Can't resolve 'http' in 'C:\Dev Projects\xAPI Angular Example\xAPIExample\node_modules\tincanjs\node_modules\xhr2\lib'
ERROR in ./node_modules/tincanjs/node_modules/xhr2/lib/xhr2.js
Module not found: Error: Can't resolve 'https' in 'C:\Dev Projects\xAPI Angular Example\xAPIExample\node_modules\tincanjs\node_modules\xhr2\lib'
ERROR in ./node_modules/tincanjs/node_modules/xhr2/lib/xhr2.js
Module not found: Error: Can't resolve 'os' in 'C:\Dev Projects\xAPI Angular Example\xAPIExample\node_modules\tincanjs\node_modules\xhr2\lib'

The TincanJS libarary has a dependency on the xhr2. I have checked the physical folder and the xhr2.js file exists in the right location.

I was wondering what am i doing wrong? Can you help

John Velasquez

remove the xhr2

it should be,

"scripts": [
    "node_modules/tincanjs/build/tincan-min.js"
]

For declaration, instead of

import * as TinCan from 'tincanjs';

use

declare const TinCan: any;

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Angular 6 setTimeout Module not found: Error: Can't resolve 'timers'

ERROR in "path" Module not found: Error: Can't resolve - Angular 6 Webpack

Update to Angular v6 - Module not found: Error: Can't resolve 'fs'

Importing jquery in Angular6 : Module not found: Error: Can't resolve 'jquery'

Angular 2 - Module not found: Error: Can't resolve '@angular/material'

Error: Module not found: Error: Can't resolve '@angular/cdk/scrolling'

Module not found: Error: Can't resolve 'http' in selenium-webdriver

Module not found: Error: Can't resolve 'http' in React

Angular 8 - Module not found: Error: Can't resolve 'fs' in

Module not found: Error: Can't resolve '@angular/core'

Module not found: Error: Can't resolve '@angular/animations'

Angular 2: Module not found: Error: Can't resolve

Module not found Error : Can't resolve './ ' in Angular8

Module not found: Error: Can't resolve 'module

Module not found: Error: Can't resolve 'uuid' in

Module not found: Error: Can't resolve 'hammerjs'

Module not found: Error: Can't resolve './templates'

Module not found: Error: Can't resolve 'util'

Module not found: Error: Can't resolve './components'

Module not found: Error: Can't resolve 'fs'

Module not found: Error: Can't resolve 'ReactDOM'

Module not found: Error: Can't resolve 'avoriaz'

Module not found: Error: Can't resolve 'dropzone'

MUI : Module not found "Module not found: Error: Can't resolve 'moment' "

Angular2/4 Module not found: Error: Can't resolve 'three' in '..\app' resolve 'three' in '..\app'

Module not found: Error: Can't resolve './app.module.ngfactory' - ionic 3, angular 5

Angular 5: Module not found: Error: Can't resolve '@angular/forms/src/validators'

Module not found: Error: Can't resolve '@angular/cdk/tree' '@angular/material/tree'

Get error in Angular 7 ./src/app/app.component.ts Module not found: Error: Can't resolve