最近在看TJ大神的 node in action 实验了其中的socket实时聊天网页,启动后报404错误,也就是找不到index.htm页,不知道各位有没有遇到,自己对了一下写的路径,应该没什么错误,请教大家,读取文件的话路径应该怎样写?
回复 (15)
Z
module.exports = function () { console.log('启动的目录:' + process.cwd()); console.log('工作的目录:' + __dirname); }
M
__dirname 项目路径 ./ 当前路径
Y
T
引用 tsregll这是代表根目录下的txt文件么?
@brighthas Well Ok I'll continue to read node in action ,thank you so much
B
引用 tsregll这是代表根目录下的txt文件么?
@tsregll
This is the basic knowledge you need to educate yourself.
签名: 交流群244728015 《Node.js 服务器框架开发实战》 http://url.cn/Pn07N3
T
T
__dirname? is working directory or source file directory?
R
B
引用 tsregll这是代表根目录下的txt文件么?
@ringtail lol , many people buy, before the end of price increases.
签名: 交流群244728015 《Node.js 服务器框架开发实战》 http://url.cn/Pn07N3
R
T
能给个 __dirname
T
T
这是代表根目录下的txt文件么?
B
参与回复
登录后即可参与回复。登录