GitHub Documentation Patreon donate button

Problem with colyseus.js and webpack



  • Hello,
    I'm new with node.js and Colyseus and I'm a little bit confused with configuration files, npm packages, etc.
    I've developed a game using Colyseus. Initially I wrote it in Javascript, and is running ok. After that I migrated code to Typescript and used Wepback in client side. I installed Colyseus.js with npm install --save colyseus.js, and when try to import in my code with import * as Colyseus from "colyseus.js" VS code complaints with "Cannot find module 'colyseus.js' or its corresponding type declarations." Same error when I try compile with webpack.
    My client side programs are in a subfolder of the main project folder. Have I to configure webpack or tsconfig in any special way? Do I need a package.json in my client subfolder? Or the problem is in other side I cannot see...
    Thanks in advance.



  • SOLVED!
    I had "module": "ES6" in tsconfig.json. Changed to "module": "commonjs", and now can find the colyseus.js module.
    Colyseus is great but configuration files are a nightmare!


 

© 2020 Endel Dreyer