JCMais / node-libcurl

libcurl bindings for Node.js
https://npmjs.org/package/node-libcurl
MIT License
666 stars 118 forks source link

error: 'No loader is configured for ".node" files: node_modules/node-libcurl/lib/binding/node_libcurl.node' #379

Closed yaruo-react-redux closed 8 months ago

yaruo-react-redux commented 1 year ago

I have an error when I try to debug my code. I created this project using vite.

Describe the bug

I have an error as follows when I debug my code.

  const handleFetchToken = async () => {
    const userArgs: { [key: string]: string } = {
      username: 'wp-username',
      password: 'wp-password',
    };
    const url = 'https://<my_wordpress>/wp-json/api/v1/token';

    const curl = new Curl();
    curl.setOpt(Curl.option.URL, url);
    curl.setOpt(Curl.option.POSTFIELDS, querystring.stringify(userArgs));
    curl.setOpt(Curl.option.VERBOSE, true);

    curl.on('end', (statusCode, body) => {
      console.log('Body received from httpbin:');
      console.log(body);

      curl.close();
    });

    curl.on('error', curl.close.bind(curl));
    curl.perform();
  };

error message:

  errors: [
    {
      detail: undefined,
      id: '',
      location: {
        column: 25,
        file: 'node_modules/node-libcurl/dist/Multi.js',
        length: 34,
        line: 5,
        lineText: "const bindings = require('../lib/binding/node_libcurl.node');",
        namespace: '',
        suggestion: ''
      },
      notes: [],
      pluginName: '',
      text: 'No loader is configured for ".node" files: node_modules/node-libcurl/lib/binding/node_libcurl.node'
    }
  ],
  warnings: []
}

Version information:

Version:

Version: libcurl/7.86.0 OpenSSL/3.0.5 zlib/1.2.11 brotli/1.0.9 zstd/1.4.9 libidn2/2.1.1 libssh2/1.10.0 nghttp2/1.47.0
Protocols: dict, file, ftp, ftps, gopher, gophers, http, https, imap, imaps, ldap, ldaps, mqtt, pop3, pop3s, rtsp, scp, sftp, smb, smbs, smtp, smtps, telnet, tftp
Features: AsynchDNS, Debug, TrackMemory, IPv6, Largefile, NTLM, NTLM_WB, SSL, libz, brotli, TLS-SRP, HTTP2, UnixSockets, HTTPS-proxy, alt-svc

OS: macOS Ventura 13.1 Node.js Version: 18.12.1

TypeScript: 4.9.4 vite: 4.0.4

If you need more information, please let me know.

Thank you.

ddolcimascolo commented 11 months ago

Hi @yaruo-react-redux

You must have figured it now I suppose, but this library is a Node binding for libcurl. Basically it runs native C/C++ code which cannot be run in a browser, albeit not easily (think WASM). This library runs in Node only.

Cheers, David