How I Work Around The require(“../../../../../../../”) Problem In NodeJS
21–30 of 44 posts
Re: How I Work Around The require(“../../../../../../../”) Problem In NodeJS
#22Re: How I Work Around The require(“../../../../../../../”) Problem In NodeJS
#23Re: How I Work Around The require(“../../../../../../../”) Problem In NodeJS
#24For me, a relative path in a require statement signifies that the required code is a part of the application itself. Consider: require('foo'); Versus: require('./foo'); If I find that a module is becoming popular, I may turn it into an npm module by moving it to it's own folder and adding a package.json, then using npm's bundledDependencies property to inform npm that it lives locally. (edit: Note that I've shifted m…
Re: How I Work Around The require(“../../../../../../../”) Problem In NodeJS
#25 npm link lib
link -s lib node_modules/lib
Then: require('lib/models/user')
No matter where you are.Re: How I Work Around The require(“../../../../../../../”) Problem In NodeJS
#26For me, a relative path in a require statement signifies that the required code is a part of the application itself. Consider: require('foo'); Versus: require('./foo'); If I find that a module is becoming popular, I may turn it into an npm module by moving it to it's own folder and adding a package.json, then using npm's bundledDependencies property to inform npm that it lives locally. (edit: Note that I've shifted m…
require('foo');
and application files like: require('./foo.js'); //.js extensionRe: How I Work Around The require(“../../../../../../../”) Problem In NodeJS
#27can't you install a private npm module by npm link? That won't touch the npm servers [1]. Then your other project in the same file system can just require like a first class public npm module. [1] https://www.npmjs.org/doc/cli/npm-link.html
I don't think npm link is meant to be used in production like that.