S
S
Svyatoslav Khusamov2017-01-25 14:48:35
Node.js
Svyatoslav Khusamov, 2017-01-25 14:48:35

How to specify a folder for your modules in Node.js (without npm)?

I made a test index.js file in the folder:
C:\@repositories\element2\index.js

process.env.NODE_PATH = "C:\\@repositories\\element2\\modules";
require("node-firebird-promise-old");

In folder:
C:\@repositories\element2\modules\node-firebird-promise-old
I have a module. Specifically there is an index.js file.
When I run C:\@repositories\element2\index.js I get the error
module.js:471
throw err;
^
Error: Cannot find module 'node-firebird-promise-old'

How can I write NODE_PATH inside the script so that Node finds the right module ???
I tried setting NODE_PATH outside the script
NODE_PATH=C:/@repositories/element2/modules
That's how it works. But I need to specify this inside the script so as not to depend on absolute paths, which, in addition, are set outside the script.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
Y
Yustas Alexu, 2017-01-25
@khusamov

Use this module app-module-path-node

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question