简体   繁体   English

使用 Nodejs Sharp 模块时出错。 模块解析失败:意外字符 '' (1: 0)

[英]Error when using the Nodejs Sharp module. Module parse failed: Unexpected character '' (1: 0)

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 "运行 webpack 时,我收到此错误“警告 in./node_modules/sharp/build/Release/sharp.node 1:0 模块解析失败:意外字符 '' (1:0) 您可能需要适当的加载程序来处理此文件类型, 目前没有配置加载器来处理这个文件. 见https://webpack.js.org/concepts#loaders (这个二进制文件省略了源代码) @./node_modules/sharp/lib/constructor.js 11: 2 -40 @./node_modules/sharp/lib/index.js "

Sharp was installed with the yarn add. Sharp 是通过添加纱线安装的。 My operating system is ubuntu 18.04 x86_64.我的操作系统是 ubuntu 18.04 x86_64。 How can I solve this problem?我怎么解决这个问题?

If you use webpack, use node-loader如果您使用 webpack,请使用node-loader

Install it: npm i -D node-loader安装它: npm i -D node-loader

In webpack.config.js :webpack.config.js

module: {
  rules: [
    { test: /\.ts$/, loader: "ts-loader" },  
    { test: /\.node$/, use: "node-loader"}
  ]
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM