Reputation: 2720
I am trying to use TypeScript with node, socket.io and webpack.
I have set up webpack.config.js
, tsconfig.json
and tsd.json
and downloaded the typings file for socket.io from the DefinitelyTyped repository using tsd
. I have installed socket.io with npm
.
When I run:
webpack
I get the following error:
ERROR in ./~/socket.io/lib/index.js
Module not found: Error: Cannot resolve module 'fs' in /private/tmp/ts-test/node_modules/socket.io/lib
@ ./~/socket.io/lib/index.js 7:11-24
It appears webpack cannot resolve the inclusion of a module from within the node_modules directory.
My versions are:
I have published a small example to this repository: https://github.com/cubabit/typescript-problems
Upvotes: 0
Views: 665
Reputation: 276363
Error: Cannot resolve module 'fs' in /private/tmp/ts-test/node_modules/socket.io/lib
That file should not be loaded in the frontend. You are loading the backend / nodejs javascript files of NodeJS.
Socket.io comes with both the backend and frontend.
For a working example give http://alm.tools/ source code a go.
Upvotes: 2