question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Respect NODE_PATH environment variable

See original GitHub issue

I wanted to try out create-react-app on our internal monorepo, which is basically structured into 2 folders: “apps” and “components”.

The “apps” contain just an entry index.js file and their build/transpile configuration and import a root component from the components directory.

This is currently solved by directing imports using NODE_PATH environment variable to make tools look into the components folder (so that you can write import Button from 'ns-button' instead of import Button from '../../../components/ns-button).

Personally I would feel that this would be worthwhile to support so this project could work with a wide variety of “non-standard” project layouts.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

3reactions
cpojercommented, Jul 29, 2016

(@lacker: Jest does handle NODE_PATH just fine. It also has a moduleDirectories option).

2reactions
mxstbrcommented, Jul 28, 2016

We do this in react-boilerplate with the webpack option, not sure what the up and/or downsides of this approach are:

resolve: {
  modulesDirectories: ['app', 'components', 'node_modules']
}

Ref: https://webpack.github.io/docs/configuration.html#resolve-modulesdirectories

Read more comments on GitHub >

github_iconTop Results From Across the Web

Node.js NODE_PATH environment variable - Stack Overflow
During development I used to WebStorm node_path =. environment variable. I have set up a variable in the launch of the project settings....
Read more >
[Proposal] Make node name accessible as environment variable
From the NODE_PATH environment variable you pointed out, I come to a little concerns that the name path may be mistaken as the...
Read more >
Node.js - Environment Setup - Tutorialspoint
The installer should set the C:\Program Files\nodejs\bin directory in window's PATH environment variable. Restart any open command prompts for the change to ...
Read more >
Location Paths (XSLT)
A location path describes the location of something in an XML document. ... you can focus on the current directory and ignore the...
Read more >
NODE_PATH is not set, and node won't find modules installed ...
... if I pass the appropriate environment variable: [orion@mrsa src]$ ... design decision by node and npm upstream which Fedora respects.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found