rodgc / ngx-socket-io

Socket.IO module for Angular
MIT License
261 stars 89 forks source link

Cannot assign to read only property 'exports' of object '[object Object]' #72

Closed kylekatarnls closed 4 months ago

kylekatarnls commented 4 years ago

👋 Hello,

I updated an Angular 7 project where ngx-socket-io worked well to Angular 10 (and ngx-socket-io 3.2.0).

Now starting the project with ng serve show a blank page, and I get this error in the console:

common.js:266 Uncaught TypeError: Cannot assign to read only property 'exports' of object '[object Object]'
    at Module.<anonymous> (common.js:266)
    at Module../node_modules/debug/src/common.js (vendor.js:151074)
    at __webpack_require__ (bootstrap:84)
    at Object../node_modules/debug/src/browser.js (browser.js:250)
    at __webpack_require__ (bootstrap:84)
    at Object../node_modules/socket.io-client/lib/url.js (url.js:7)
    at __webpack_require__ (bootstrap:84)
    at Object../node_modules/socket.io-client/lib/index.js (index.js:6)
    at __webpack_require__ (bootstrap:84)
    at Module../node_modules/ngx-socket-io/fesm2015/ngx-socket-io.js (vendor.js:175161)
(anonymous) @ common.js:266
./node_modules/debug/src/common.js @ vendor.js:151074
__webpack_require__ @ bootstrap:84
./node_modules/debug/src/browser.js @ browser.js:250
__webpack_require__ @ bootstrap:84
./node_modules/socket.io-client/lib/url.js @ url.js:7
__webpack_require__ @ bootstrap:84
./node_modules/socket.io-client/lib/index.js @ index.js:6
__webpack_require__ @ bootstrap:84
./node_modules/ngx-socket-io/fesm2015/ngx-socket-io.js @ vendor.js:175161
__webpack_require__ @ bootstrap:84
./src/app/app.module.ts @ app.module.ts:8
__webpack_require__ @ bootstrap:84
./src/main.ts @ main.ts:4
__webpack_require__ @ bootstrap:84
0 @ main.ts:12
__webpack_require__ @ bootstrap:84
checkDeferredModules @ bootstrap:45
webpackJsonpCallback @ bootstrap:32
(anonymous) @ main.js:1

So the following line in ngx-socket-io: https://github.com/rodgc/ngx-socket-io/blob/v3.2.0/src/socket-io.service.ts#L5

If I comment the SocketIoModule.forRoot() import in app.module.ts:

@NgModule({
  declarations: [
    AppComponent,
  ],
  imports: [
    BrowserModule,
    BrowserAnimationsModule,
    CommonModule,
    ...,

    // SocketIoModule.forRoot({
    //   url: 'http://localhost:3042',
    // }),
  ],
  providers: [
    SocketService,
  ],
  bootstrap: [
    AppComponent,
  ],
})
export class AppModule {
}

The index page is probably displayed again with no errors.

Can you see what's wrong here?

Thank you for this helpful library ❤️

kylekatarnls commented 4 years ago

As a work-around, I downgraded socket.io-client from 2.3.0 to 2.2.0 and it sounds to work fine again.

github-actions[bot] commented 4 months ago

This issue is stale because it has been open for 30 days with no activity.

github-actions[bot] commented 4 months ago

This issue was closed because it has been inactive for 7 days since being marked as stale.