Reputation: 16469
I have this line of code in my file:
import appRoutes from process.ROOTDIR + '/../app/routes.js';
I am getting the error:
SyntaxError: /Users/bli1/Development/Javascript/ReviewWeb/server/api/helpers/isomorphic.js: Unexpected token (6:22)
4 | import Router from'react-router';
5 | import Log from'loglevel';
> 6 | import appRoutes from process.ROOTDIR + '/../app/routes.js';
Is there a way I can have a global ROOTDIR
variable so I don't have to add ../../..
everywhere?
Upvotes: 1
Views: 65
Reputation: 664528
No. The import name is always a string literal.
Depending on your module loader, you might make it resolve names like /app/routes.js
using a given root directory though. Have a look at its docs and what hooks are supported.
Upvotes: 2