Skip to content

Commit fb471b5

Browse files
committed
node path
1 parent 50c5638 commit fb471b5

File tree

7 files changed

+54
-3
lines changed

7 files changed

+54
-3
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
3+
# Example project - using NODE_PATH env variable
4+
5+
6+
run any of the index.sh files, and you will see how NODE_PATH incorporates the node_modules folder from the
7+
parent directory.

foobar1/index.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
const assert = require('assert');
3+
const webpack = require('webpack');
4+
5+
console.log('webpack =>', webpack);
6+
assert(webpack);

foobar1/index.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env bash
2+
3+
cd "$(dirname "$0")"
4+
5+
parent_node_modules="$(dirname $(dirname $(npm root)))/node_modules";
6+
7+
echo "parent_node_modules => $parent_node_modules"
8+
9+
NODE_PATH="$NODE_PATH:$parent_node_modules" node . # same as: node index.js

foobar2/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
3+
const assert = require('assert');
4+
const webpack = require('webpack');
5+
6+
console.log('webpack =>', webpack);
7+
assert(webpack);

foobar2/index.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env bash
2+
3+
cd "$(dirname "$0")"
4+
5+
parent_node_modules="$(dirname $(dirname $(npm root)))/node_modules";
6+
7+
echo "parent_node_modules => $parent_node_modules"
8+
9+
NODE_PATH="$NODE_PATH:$parent_node_modules" node . # same as: node index.js

foobar3/index.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
2+
3+
const assert = require('assert');
4+
const webpack = require('webpack');
5+
6+
console.log('webpack =>', webpack);
7+
assert(webpack);

foobar3/index.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,9 @@
1-
#!/usr/bin/env bash
1+
#!/usr/bin/env bash
2+
3+
cd "$(dirname "$0")"
4+
5+
parent_node_modules="$(dirname $(dirname $(npm root)))/node_modules";
6+
7+
echo "parent_node_modules => $parent_node_modules"
8+
9+
NODE_PATH="$NODE_PATH:$parent_node_modules" node . # same as: node index.js

0 commit comments

Comments
 (0)