Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

612
Visualizações
What's the difference between node:process and process?

When I import node:process it works fine. However, when I try to require the same, it gives an error.

This works fine:

import process from 'node:process';

But when I try to require the same, it throws an error:

const process = require('node:process');

Error: Cannot find module 'node:process'

I am curious as to what is the difference between process, which works in both, commonjs and module, vs node:process.

Also, a follow-up, I am using webpack to bundle my js, and I discovered this error when I tried to run my bundled code and realised, that chalk imports node:process, node:os and node:tty. How do I solve that now?

about 4 years ago · Juan Pablo Isaza
2 Respostas
Responde à pergunta

0

import process from 'node:process'; and import process from 'process'; are equivalent.

The node: exists since version 12 for import.

node: URLs are supported as an alternative means to load Node.js builtin modules. This URL scheme allows for builtin modules to be referenced by valid absolute URL strings.

The idea behind node: is to make clear that it is actually a buildin module and not one installed and to avoid name conflicts, with 3rd party modules.

The node: protocol was first added only for import so a particular node version might support node: with import but not with require.

In v16.13.0 (not sure since which v16 version) you can also use it with require. And was also backported to v14 since v14.18: module: add support for node:‑prefixed require(…) calls

about 4 years ago · Juan Pablo Isaza Relatório

0

"node:" is an URL scheme for loading ECMAScript modules. As such it started for "import", not "require".

"node:process" is just an alternative name to load the built-in "process" module.

See also Node.js documentation - you can find the lowest supporting Node.js version inside the "History" tag (12.20.0, 14.13.1)

With newer Node.js it should be available for "require" as well (14.18.0, 16.0.0).

Some more details can be found here: node:process always prefers the built-in core module, while process could be loaded from a file.

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda