我剛開始學習節點。 這裏是我的問題,我得到了sample.js文件內容未定義,錯誤是錯誤:ENOENT,打開'C: Windows system32 hello.txt'
var fs=require("fs");
console.log("starting");
fs.readFile("hello.txt" , function(error,data){
console.log("content is asdas " + data);
});
console.log("executed");
,並與內容hello.txt的,他們都是我的桌面
hello
,當我運行該管理員在PowerShell中或在cmd
C:\Windows\system32\ node C:\Users\X\Desktop\sample.js
我得到
開始
執行
含量asdas不確定
當我登錄錯誤
var fs=require("fs");
console.log("starting");
fs.readFile("hello.txt" , function(error,data){
console.log("content is asdas " + error);
});
console.log("executed");
我得到
開始
執行
內容asdas錯誤:ENOENT,打開 'C:\ WINDOWS \ SYSTEM32 \ hello.txt的'
所以我想這個錯誤是節點正在尋找在system32下,不在桌面...?
謝謝!
是............ –