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

459
Visualizações
Cannot read property 'defaultEncoding' in s3sync Plugin of Serverless framework

I had installed the plugin by following command in serverless 2.53.1.

npm install --save-dev serverless-s3-sync

After installing I had imported the plugin like this in serverless.yml

plugins:
    - serverless-plugin-common-excludes
    - serverless-plugin-include-dependencies
    - serverless-python-requirements 
    - serverless-s3-sync

But (serverless deploy) is giving the following error. Screenshot of error is also attached. (This error only happens when I import this plugin of serverless-s3-sync in serverless.yml file other plugins are running fine).

ERROR DETAILS:

TypeError: Cannot read property 'defaultEncoding' of undefined at _write (node:internal/streams/writable:291:24) at WriteStream.Writable.write (node:internal/streams/writable:334:10) at NodejsStreamOutputAdapter.ondata (C:\serverless_v2\node_modules\readable-stream\lib_stream_readable.js:619:20) at NodejsStreamOutputAdapter.emit (node:events:394:28)

Here's a full error:

enter image description here

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

I got this error message twice from Serverless Framework. The error message is not descriptive for the root cause. The way I could resolve it was:

  • Delete the two directories named (1) node_modules and (2) .serverless
  • Reinstall the dependencies using serverless instead of npm e.g. serverless plugin install -n serverless-s3-sync

Now I could deploy the project again. But the error message is misleading and should be considered an error in itself that the error message is a source of painful confusion.

over 4 years ago · Santiago Trujillo Relatório

0

After a lot of digging, I isolated the cause to having two different versions of graceful-fs in the resolved node sub-dependencies.

In my case I'm using the serverless-python-requirements plugin, not serverless-s3-sync, but the error is the same. Both plugins list graceful-fs as a dependency.

You can see from yarn list that there are two different versions of graceful-fs installed:

% yarn list

├─ fs-extra@9.1.0
│  ├─ at-least-node@^1.0.0
│  ├─ graceful-fs@^4.2.0
│  ├─ jsonfile@^6.0.1
│  └─ universalify@^2.0.0
…
├─ graceful-fs@4.2.2 ← version used by fs-extra, required by jsonfile
…
├─ jsonfile@6.1.0
│  ├─ graceful-fs@^4.1.6
│  ├─ graceful-fs@4.1.15 ← version used by jsonfile
│  └─ universalify@^2.0.0
…

It seems that the stream objects created by one version of this library are not consumable by the other version.

With yarn I solved this by pinning graceful-fs to the latest version by adding this to my package.json file:

  "resolutions": {
    "**/graceful-fs": "4.2.8"
  }

For npm it should be possible to achieve the same thing using npm-force-resolutions, but it appears the syntax is slightly different (I have not tested this):

  "resolutions": {
    "graceful-fs": "4.2.8"
  }

Removing the lock file and node_modules folder and reinstalling might solve the problem, but given the pain this has caused, I was happier to pin the version in package.json.

over 4 years ago · Santiago Trujillo 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