Angular 2 Cli - Import of Socket.IO - module not found
Please provide us with the following information:
OS?
Mac OSX Sierra
Versions.
angular-cli: 1.0.0-beta.16 node: 6.7.0 os: darwin x64
Repro steps.
Yes.. I have made a few components. The issue lies where I try to import the socket.io-client library from node_modules, I get the following error on the terminal:
ERROR in [default] /Applications/MAMP/htdocs/foldername/project-socketio/client/src/app/chat.service.ts:5:20 Cannot find module 'socket.io-client/socket.io'.
The Component/Service file I am trying to import it to looks like this, I have reduced the code for brevity:
import { Injectable } from '@angular/core'; import { Subject } from 'rxjs/Subject'; import { Observable } from 'rxjs/Observable'; import * as io from 'socket.io-client';
--- In polyfills.ts file I added this line import 'socket.io-client/socket.io';
and typings.json file:
{ "globalDependencies": { "socket.io-client": "registry:dt/socket.io-client#1.4.4+20160317120654" } }
I installed typings: npm install --save @types/socket.io-client
I also added this to the angular-cli.json file: "scripts": ["../node_modules/socket.io-client/socket.io.js"],
Not sure what else I can do.. I used to use systemjs.config for pulling in 3rd party libs but I see that this ngCli uses webpack.. is there another step I should be taking....
The log given by the failure.
Normally this include a stack trace and some more information.
Mention any other details that might be useful.
Thanks! We'll be in touch soon.
Try add to src/typings.d.ts this line before declare var System: any;
/// <reference path="../typings/index.d.ts" />
Cheers, In the end it started working and in typical developer fashion: it doesnt work, I have no idea why.... it works, I have no idea why
Possibly because the last attempt I used Yarn as a package manager to reinstall the dep's rather thatn NPM... I'll keep this in mind though if I ever come across it again. Cheers
Closing as it seems resolved.
He working
This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.