Error: You may need an appropriate loader to handle this file type


#1

Hey, I’m new to ionic.
I’m trying to use an npm module called ‘odoo’. and its brings JSONStream.
Sadly that gives the following error:

RROR in ./~/JSONStream/index.js
Module parse failed: /home/nagel/workspace/ionic/MyIonic2Project/node_modules/JSONStream/index.js Line 1: Unexpected token ILLEGAL
You may need an appropriate loader to handle this file type.
| #! /usr/bin/env node
| 
| var Parser = require('jsonparse')
 @ ./~/jayson/lib/utils.js 2:17-38

I’m importing odoo as this:
import Odoo from 'odoo';

If i remove the
#! /usr/bin/env node
line i get the following error:
Uncaught TypeError: Cannot read property 'prototype' of undefined http://localhost:8100/build/js/app.bundle.js Line: 69227

this module works in a simple node project, and i need this module to work.


#2

So from the looks of the module, you’re trying to load javascript thats meant to be used in node land, not the browser. Thats probably where you’re having issues.


#3

SOLVED! For me the issue was the commented code at the end of the file:
Example:

/*
import { Http } from '@angular/http';

@Component({
  selector: 'page-login',
  templateUrl: 'login.html'
})

export class LoginPage {}
*/

Removing it, or fully commenting it.
…fixes the issue