Adonis is not defined - Trouble with React/Cordova App


Hello, im currently building an app using web react and cordova

I follow the steps:

  • npm i @adonisjs/websocket-client

then i installed polyfill via babel and improted it into node_modules/@adonisjs/websocket-client/dist/Ws.browser.js

then when i ran the code, i face the error:

Ws.browser.js:9 Uncaught TypeError: Cannot read property ‘adonis’ of undefined
at eval (Ws.browser.js:9)
at Module.eval (Ws.browser.js:10)
at eval (Ws.browser.js:2520)
at Module…/node_modules/@adonisjs/websocket-client/dist/Ws.browser.js (app.js:804)
at webpack_require (app.js:724)
at fn (app.js:101)
at eval (client_websocket.js:3)
at Module…/src/js/client_websocket.js (app.js:9747)
at webpack_require (app.js:724)
at fn (app.js:101)

here is the Ws.browser.js

1 Like


Hi @renanmiyata

I ran into the same issue with Vue:

In short:
Transpile @adonisjs/websocket-client/index not @adonisjs/websocket-client
Import @adonisjs/websocket-client/index not @adonisjs/websocket-client

This is already built in module. It is general rule of thumb to not edit anything in node_modules folder.

1 Like