404 using Angular2, angular2-websocket and typings

...
import {$WebSocket} from "angular2-websocket/angular2-websocket";

@Injectable()
export class DeviceService {

    private logger:Logger;
    private ws:$WebSocket;

    constructor(
        private _logger: Logger
    ) {
        this.logger=_logger;
        this.ws = new $WebSocket("ws://nodered-iot.net/ws/devices");
    }

    private _devices:Device[] = [];

    getDevices() {

        this.ws.send("Hello");
   ...

On my browser I get this :

GET http://localhost:1880/node_modules/angular2-websocket/angular2-websocket 404 (Not Found)I @ system.src.js:4597(anonymous function) http://localhost:1880/node_modules/angular2-websocket/angular2-websocket(…)

I use this definition on index.html

<!-- 2. Configure SystemJS -->
<script>
    System.config({
        transpiler: 'typescript',
        typescriptOptions: { emitDecoratorMetadata: true },
        packages: {'app': {defaultExtension: 'ts'}},
        map: {
            'angular2-websocket': 'node_modules/angular2-websocket'
        }
    });
    System.import('app/main')
            .then(null, console.error.bind(console));
</script>

****** EDIT *******

i successfully found the FIX as it :

System.config({ transpiler: 'typescript', typescriptOptions: { emitDecoratorMetadata: true }, packages: { 'app': {defaultExtension: 'ts'}, 'js': { defaultExtension: 'ts' }}, map: { 'angular2-websocket': 'js' } }); System.import('app/main') .then(null, console.error.bind(console));

I had to copy files from node_module into a new js folder. This is not very nice but I don't know how to make this available on client side if these files are not on the 'public' folder of nodeJs :/

Answers


I think that it's a SystemJS configuration. You try this:

<script>
  System.config({
    map: {
      'angular2-websocket': 'node_modules/angular2-websocket'
    },
    packages: {
      (...)
    }
  });
</script>

Anoher solution is to change the Root of NodeRed as it instead pointing to 'public' folder :

// Serve up the welcome page
httpStatic: path.join(__dirname,"/"),

then we can declare on the index.html :

<script src="/node_modules/angular2-websocket/angular2-websocket.js"></script>

Need Your Help

How to search into table B if the result of searching into table A is zero?

php mysql performance pdo

I have three tables and I need to search in the first one, it there isn't any result, then search into second one and so on ..!

Vim SQL omnicomplete

vim omnicomplete vim-plugin

I'm trying to use the dynamic SQL auto completion (omni menu) feature in vim, but it's not working.