From 264fc12e607968e4a38d2cd1cac0e07840ee6d8c Mon Sep 17 00:00:00 2001 From: Amanda Simon Date: Wed, 21 Sep 2016 10:18:09 -0400 Subject: [PATCH] Add documentation for existing work-around for importing components using asbolute paths. --- packages/react-scripts/template/README.md | 28 +++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/packages/react-scripts/template/README.md b/packages/react-scripts/template/README.md index 085406077b5..e8238b080f1 100644 --- a/packages/react-scripts/template/README.md +++ b/packages/react-scripts/template/README.md @@ -205,6 +205,34 @@ class Button extends Component { export default Button; // Don’t forget to use export default! ``` +To import your own modules into other files, you can use relative paths by default. For example: +```js +import Banana from '../../Banana'; +``` +You can also enable absolute paths by adding a NODE_PATH environment variable. This is a bit of a stop-gap measure for now. Here is an example absolute import and the commands you would need to run for it to work: + +```js +import Banana from 'fruits/Banana'; // fruits is a subdirectory of src +``` + +If you use Bash on OS X or Linux: + +```js +NODE_PATH=./src npm start +NODE_PATH=./src npm run build +NODE_PATH=./src npm test +``` + +If you use Cmd on Windows: + +```js +NODE_PATH=./src&&npm start +NODE_PATH=./src&&npm run build +NODE_PATH=./src&&npm test +``` + +Note that lack of whitespace on Windows is intentional. + ### `DangerButton.js`