Error when using the Nodejs Sharp module. Module parse failed: Unexpected character '' (1: 0)
Asked Answered
A

1

5

When running webpack I have received this error "WARNING in ./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) @ ./node_modules/sharp/lib/constructor.js 11: 2-40 @ ./node_modules/sharp/lib/index.js "

Sharp was installed with the yarn add. My operating system is ubuntu 18.04 x86_64. How can I solve this problem?

Annabelleannabergite answered 19/8, 2020 at 2:8 Comment(0)
E
9

If you use webpack, use node-loader

Install it: npm i -D node-loader

In webpack.config.js:

module: {
  rules: [
    { test: /\.ts$/, loader: "ts-loader" },  
    { test: /\.node$/, use: "node-loader"}
  ]
}
Egidio answered 5/1, 2021 at 21:23 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.