Start/package.json not found hooks.js

Hello, how are you? I am following the websockets tutorial here:
https://adonisjs.com/docs/4.1/websocket

and in start / hook.js is giving the following error:

Error: Cannot find module ‘/var/www/html/chatcomposer/start/package.json’
at /var/www/html/chatcomposer/start/hooks.js(anonymous):7
2 const { Ignitor } = require(’@adonisjs/ignitor’)
3
4 new Ignitor(require(’@adonisjs/fold’))
5 .appRoot(__dirname)
6 .wsServer() // boot the WebSocket server
7 .fireHttpServer()
8 .catch(console.error)
9
1 Ignitor._setPackageFile
/var/www/html/chatcomposer/node_modules/@adonisjs/ignitor/src/Ignitor/index.js:149

2 Ignitor.fire
/var/www/html/chatcomposer/node_modules/@adonisjs/ignitor/src/Ignitor/index.js:738
3 Ignitor.fireHttpServer
/var/www/html/chatcomposer/node_modules/@adonisjs/ignitor/src/Ignitor/index.js:810
Application crashed, make sure to kill all related running process, fix the issue and re-run the app

apparently he’s trying to find a file in the “start” folder that doesn’t exist could someone explain to me why this?

1 Like

File: start/hook.js
change:
.appRoot(__dirname)
to:
.appRoot(__dirname.replace(’/start’, ‘’))

The error stopped but I do not know if this is correct … the path should not come correct by default?

2 Likes

Can you show what’s inside start/hooks.js? It sounds like something is referencing package.json in there and that something is expecting to be on the root directory

Something near line 7

const { Ignitor } = require(’@adonisjs/ignitor’)

new Ignitor(require(’@adonisjs/fold’))

.appRoot(__dirname.replace(’/start’, ‘’))

.wsServer() // boot the WebSocket server

.fireHttpServer()

.catch(console.error)

Why is it in your start/hooks.js? It should be in server.js at project root :wink:

2 Likes