Eslint and using NODE_PATH env var to import modules

I get errors in local modules.

To start the application, follow these steps:

"start": "NODE_PATH=\"$(pwd)\" node -r babel-register -r babel-polyfill src/index.js",

By setting NODE_PATH to the root directory where package.json is located, it allows me to write import from the root:

import config from 'src/utils/config';

This annoys the import/no-extraneous-dependencies rule. If I write a relative path, he will not complain. Is there any way for eslint recognize the root directory as the starting path for module import paths?

+5
source share

Source: https://habr.com/ru/post/1263393/


All Articles