Open file in another folder with node js

2019-09-19 06:04发布

问题:

I am trying to open a file on another folder with nodejs using an absolute path.
This file contains a js program that has to be executed the node.
I am using johnny five to program an Arduino but the file is not in the same folder as the node files and the libraries.
How can this be done?

回答1:

 require('C:\\run.js')

This will get 'run.js' file from C disk. But if you already tried this, than please can you explain in more detail what you want to do?