Issue with consign and express paths
I managed to find a solution to my problem and felt that I should post an answer to help others.
Essentially, as shown above I was using a relative path like so:
consign({ cwd: './artifact/server/api' }) .include('models') .then('middleware') .then('routers') .into(app);
which when called from the root directory resulted in consign not working. This can be fixed by making use of path
I added this at the top of my server.js
file:
const path = require('path');
and then changed my consign init to:
consign({ cwd: path.join(__dirname, 'api') }) .include('models') .then('middleware') .then('routers') .into(app);
This then fixed my issue!
I was running into the same issue and getting this error
! Entity not found
...but then read Node's path documentation and tried the following:
consign({ cwd: path.dirname(__dirname)})
Seems to be a solution if you need the working directory cwd:
to be root './'