Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

177
Vistas
"type": "module" import issue

Using js librairies, I struggle with the fact that require and import are not suitable together. When I write "type": "module" in the package.json, then import works but require doesn't, and when I don't, the opposite happens. I don't get how to import both of the two librairies.

I import fs like this :

const fs = require('fs')

and in the other file I am importing PythonShell like this :

import { PythonShell } from 'python-shell'

Is there a way to have "type" : "module" only applying for one librairy in my package.json ? Or can I import one like the other in order to use only one key word (import or require) ?

Thank you, have a great day.

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You don't necessarily need to use import to use the PythonShell class from python-shell, you can just use require() so your code would look like this

const fs = require('fs');
const PythonShell = require('python-shell').PythonShell;

// ...
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda