I'm trying to access modules, but nesting is getting a little out of hand
require("../../../Folder/Deeper/someFile")
Can i use require("Folder/Deeper/somefile")
require("Folder/Deeper/somefile")
I tried setting
require.paths = ['/media/work/Project'];
but it doesn't seem to work, and also feels a little ugly for me.
Are there any alternatives. Is there a way to write a wrapper for this?
Maybe this?
require.paths.unshift( '../../..' ); require("Folder/Deeper/somefile");
http://nodejs.org/api.html says:
require.paths An array of search paths for require (). This array can be modified to add custom paths.Example: add a new path to the top of the search listrequire.paths.unshift('/usr/local/node');
require.paths An array of search paths for require (). This array can be modified to add custom paths.
Example: add a new path to the top of the search list
require.paths.unshift('/usr/local/node');
(, ./app), - node_modules :
./app
node_modules
ln -s ../app ./node_modules
( app.)
app
require :
require
require('app/route/api')
package.json postinstall script npm install:
package.json
npm install
"scripts": { "postinstall": "ln -sf ../app ./node_modules" }
Windows ln, Windows . Windows.
ln