我遇到的問題包括要在我的NodeJs項目中執行的文件。NodeJs需要('./ file.js')問題
我在同一個目錄的兩個文件:
a.js
var test = "Hello World";
和
b.js
require('./a.js');
console.log(test);
我執行灣與js並得到錯誤ReferenceError: test is not defined
。
我已經通過文檔http://nodejs.org/api/modules.html#modules_file_modules
我缺少什麼看?提前致謝。
我們還可以在html中使用這個js文件(a.js)嗎? – 0x016F2818 2016-03-22 07:06:52