请教 fs.exists() 方法 请大牛帮忙,万分感谢
最近在看TJ大神的 node in action 实验了其中的socket实时聊天网页,启动后报404错误,也就是找不到index.htm页,不知道各位有没有遇到,自己对了一下写的路径,应该没什么错误,请教大家,读取文件的话路径应该怎样写?
__dirname + "/yourfile.txt"
签名: 交流群244728015 《Node.js 服务器框架开发实战》 http://url.cn/Pn07N3
这是代表根目录下的txt文件么?
no, mean is current code path.
@brighthas给个路径的实例呗,作者给的inde.htm的路径是“./public/index.htm”
能给个 __dirname
@brighthas 兄弟,你这个太贵了…
@ringtail lol , many people buy, before the end of price increases.
@brighthas …
__dirname? is working directory or source file directory?
@brighthas__dirname是什么?给一个实例吧。如:"./publc" 其中"./"代表什么什么
@tsregll
This is the basic knowledge you need to educate yourself.
@brighthas Well Ok I’ll continue to read node in action ,thank you so much
是应该补补基础知识了,全局对象啊。。。
__dirname 项目路径 ./ 当前路径
module.exports = function () { console.log(‘启动的目录:’ + process.cwd()); console.log(‘工作的目录:’ + __dirname); }
Archiver|手机版|小黑屋| PhoneGap中文网 ( 京ICP备13027796号-1 )
GMT+8, 2024-5-16 06:42 , Processed in 0.043947 second(s), 11 queries .
Powered by Discuz! X3.2
© 2001-2013 Comsenz Inc.
这是代表根目录下的txt文件么?
no, mean is current code path.
@brighthas给个路径的实例呗,作者给的inde.htm的路径是“./public/index.htm”
能给个 __dirname
@brighthas 兄弟,你这个太贵了…
@ringtail lol , many people buy, before the end of price increases.
@brighthas …
__dirname? is working directory or source file directory?
@brighthas__dirname是什么?给一个实例吧。如:"./publc" 其中"./"代表什么什么
@tsregll
This is the basic knowledge you need to educate yourself.
@brighthas Well Ok I’ll continue to read node in action ,thank you so much
是应该补补基础知识了,全局对象啊。。。
__dirname 项目路径 ./ 当前路径
module.exports = function () { console.log(‘启动的目录:’ + process.cwd()); console.log(‘工作的目录:’ + __dirname); }