I am using BrowserFS
for browser file system.
var fs = ''
var path = ''
BrowserFS.install(window)
BrowserFS.configure({ fs: 'LocalStorage' }, err => {
if (err) {
alert(err)
} else {
fs = window.fs = window.require('fs') // also tried BrowserFS.BFSRequire('fs')
path = window.path = window.require('path') // also tried BrowserFS.BFSRequire('path')
}
})
Then I tried calling it like this:
console.log(process.cwd())
console.log(__dirname)
fs.readdirSync(path.resolve(process.cwd())).forEach(file => {
console.log('file: ' + file)
})
fs.readdirSync(path.join(__dirname, '..//defaults')).forEach(file => {
console.log('__dirname file: ' + file)
})
Then I get the following errors and log outputs:
/
/
file: test.txt sample-xml-upload.vue:145
[Vue warn]: Error in mounted hook: "Error: ENOENT: No such file or directory., '/defaults'"
so:
console.log(process.cwd()) // results to /
console.log(__dirname) // results to /
How can I make the path look at the actual local location where the file is called (ex. C:\Users\Me\Desktop\NodeJS
)?
Help please!
Thanks!