Hi, I am trying to use the directory-tree module, but the function is returning null.
What am I doing wrong here? Do I need specific modules installed?
Code example:
import React, { Component } from 'react';
import directoryTree from 'directory-tree';
import _ from 'lodash';
let tree = directoryTree("C:/Users/Daniel Varzim/Desktop/Apps");
class Dummy extends Component {
render() {
console.log(tree)
return (
Hi, your issue probably is the fact that you are trying to call this from a browser where you don't have fs available. You would need a node environment.
With the project I am developing I just need a front-end for a folder containing some files.
I don´t know if I understood your answer, do I need some sort of back-end node server to run your module?
I am using react and redux, and I just want to have a const with the folder structure in json so I can display the files in the folder.
Hi, I am trying to use the directory-tree module, but the function is returning null. What am I doing wrong here? Do I need specific modules installed?
Code example:
import React, { Component } from 'react'; import directoryTree from 'directory-tree'; import _ from 'lodash';
let tree = directoryTree("C:/Users/Daniel Varzim/Desktop/Apps");
class Dummy extends Component { render() { console.log(tree) return (
} export default Dummy;
Why does "Stats" comes undefined? Is "C:/Users/Daniel Varzim/Desktop/Apps" not being considered a directory?
This is the exception I get:
"e: TypeError: FS.statSync is not a function at directoryTree"
I have the fs, fs-extra and graceful-fs modules.
Hi, your issue probably is the fact that you are trying to call this from a browser where you don't have
fs
available. You would need a node environment.With the project I am developing I just need a front-end for a folder containing some files. I don´t know if I understood your answer, do I need some sort of back-end node server to run your module?
I am using react and redux, and I just want to have a const with the folder structure in json so I can display the files in the folder.
Yes, you need a server with access to the filesystem. You can simply run an API server that serves the JSON of the folder on some endpoint.