tentwentyfour / nextcloud-link

Javascript/Typescript client that communicates with Nextcloud's WebDAV and OCS APIs
MIT License
56 stars 7 forks source link

Error using client.js #29

Closed nilskretschmer closed 3 years ago

nilskretschmer commented 3 years ago

Hi,

I am trying to get this up and running inside a Nuxt.js project. After installing the library I end up with this:

Failed to compile with 1 errors 
This dependency was not found:
* fs in ./node_modules/nextcloud-link/compiled/client.js
To install it, you can run: npm install --save fs 

I already did npm install --save fs which worked fine, but the issue remains..

Any hints?

floriansimon1 commented 3 years ago

Hi!

Do you have more information about your issue? Fetching the latest version, 1.2.3, lets me see that the file is there in my node_modules folder.

nilskretschmer commented 3 years ago

Hi, I made some screenshots of the modules and my package.json. I am using a fresh 1.2.3 version of nextcloud and installed it with npm install --save nextcloud-link. I don't see any problems here but I still get the compiling error when running npm run dev...

nextcloud_link packagesPNG modules
floriansimon1 commented 3 years ago

I'm sorry, I don't know the first thing about Nuxt. @kevinley, do you have any idea?

kwisatz commented 3 years ago

Hi @NKnuelle,

Could you please let us know which version of node you're using? And the platform (Linux, OSX, Windows) you're developing on? Having to pull in the fs package seems very odd to me since it has always been and should still be part of the core node package. That being said, note that nextcloud-link is a back-end/server package. Not sure how you were planning to use it with nuxt, but note that this will most likely never work in a browser (which might also explain the lack of an fs module in this case.).

nilskretschmer commented 3 years ago

Hi @kwisatz I am developing on a Windows 10 machine using npm 7.0.15. I just found a workaround which is mentioned here: https://github.com/nuxt-community/dotenv-module/issues/11

Following that workaround I would need to change the Webpack config to:

build: {
    extend (config, { isDev, isClient }) {

       config.node = {
            fs: 'empty'
        }

       // ....
    }
}

As you already mentioned:

That being said, note that nextcloud-link is a back-end/server package. Not sure how you were planning to use it with nuxt, but note that this will most likely never work in a browser (which might also explain the lack of an fs module in this case.).

This library won't work for my use case with/or without the workaround. I want to develop an Offline-First, client-side PWA which interacts with a remote nextcloud server. For this I would need a library which works in the browser without a nodejs server. I was not sure about this package so I gave it a try. But as you said, this won't work..

Do you know of any other Nextcloud-library (JavaScript/Typescript) that works entirely in the browser without nodejs?

kwisatz commented 3 years ago

I guess you could start by looking at libraries maintained by Nextcloud directly, such as https://github.com/nextcloud/nextcloud-axios https://github.com/nextcloud/nextcloud-axios and https://github.com/nextcloud/nextcloud-files https://github.com/nextcloud/nextcloud-files not sure though where you'd go from here.

There are other clients (https://github.com/hobigo/nextcloud-node-client and https://github.com/4workers/nextcloud-dav-client) but they both look like nodejs libraries too.

I'm not sure though this one can't be made to work in a browser. I'm not actually sure where or why the fs module is pulled in. Looking at compiled/client.js I can't actually see it, so I'm guessing it must be a sub-dependency.