Using @now/node-server
, I'm trying to achieve this:
const myLocalLibrary = require('@src/lib/myLocalLibrary');
Instead of
const myLocalLibrary = require('../../../lib/myLocalLibrary');
The problem is that I have tried multiple things that won't work, including:
Setting NODE_PATH=src
and using require('src/...
Does not work because setting NODE_PATH as env has no effect
Patching require using module-alias (https://www.npmjs.com/package/module-alias)
Works locally, fails on Zeit because node can't find any files using the module.
I used:
require("module-alias").addAlias("~", __dirname);
Is there any way of achieving this?