serverless-bundle: Module parse failed: Unexpected character '�' (1:0)

While packaging code that includes sharp ^0.22.1, I encountered this error:

ERROR in [redacted]/node_modules/sharp/build/Release/sharp.node 1:0
Module parse failed: Unexpected character '�' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
(Source code omitted for this binary file)
 @ [redacted]/node_modules/sharp/lib/input.js 5:14-52
 @ [redacted]/node_modules/sharp/lib/index.js
 @ [redacted]

About this issue

  • Original URL
  • State: open
  • Created 5 years ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

@compwright @Susan123456789 I’ve added a fix. I’ve created a beta version for you to test. Install it using:

$ npm install --save-dev serverless-bundle@beta

I’m excluding the sharp package by default. However, I’m not sure about this option that you are using:

    packagerOptions:
      scripts:
        - rm -rf node_modules/sharp && npm install --arch=x64 --platform=linux --target=8.10.0 sharp

Can you tell me what this does and if you need the plugin to have this option?