Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

496
Views
url.pathToFileURL no es una función: ¿cómo convertir una ruta de archivo en una URL en node.js?

Quiero convertir una ruta de archivo a una URL.

Traté de seguir las indicaciones que se encuentran en los documentos oficiales: https://nodejs.org/dist/latest-v16.x/docs/api/url.html#urlpathtofileurlpath

 import { pathToFileURL } from 'url' let filepathurl = pathToFileURL(file.path)

Pero me sale este error:

 Uncaught TypeError: (0 , _url.pathToFileURL) is not a function

O :

 import url from 'url' let filepathurl = url.pathToFileURL(file.path)

Mensaje de error:

 _url.default.pathToFileURL is not a function

Otra información:

 node: v16.13.0 OS : Ubuntu 20.04 Desktop

¿Qué estoy haciendo mal? ¿Como resolver el problema?

Ejemplo de ruta de archivo:

 /home/raphy/Downloads/sample.pdf

Por el momento, resolví el problema usando https://www.npmjs.com/package/file-url combinado con esta útil sugerencia para la configuración del paquete web: https://github.com/facebook/create-react-app/pull /11764#issuecomentario-1104019653

Pero me gustaría saber si y cómo usar correctamente las funciones de la biblioteca node.js

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!