H
H
hrvasiliy2015-11-05 10:58:32
Node.js
hrvasiliy, 2015-11-05 10:58:32

Why is the script not being executed from an arbitrary folder?

There is a folder on the server that contains local nodejs modules + the script itself. If a:

cd /path/to/folder/
node script.js
then everything is in order, the script is launched. But if:
node /path/to/script.js
I get an error. I think this is due to the fact that the modules are installed locally, but shouldn't the script include them based on its location?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
amatory10, 2015-11-05
@hrvasiliy

no, it does not define itself, you need to use __dirname in the script so that it looks based on the main folder, and not on the current one.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question