简体   繁体   English

错误:无法找到绑定文件。 尝试过:(Webpack)

[英]Error: Could not locate the bindings file. Tried: (Webpack)

I'm creating this small project which uses the npm package natural when I bundle the code using webpack I get these warnings. 我正在创建这个小项目,当我使用webpack捆绑代码时,会natural使用npm包,得到这些警告。

yarn run v0.18.1
$ webpack
Hash: ed778fcd450d09a90da4
Version: webpack 3.0.0
Time: 1250ms
    Asset    Size  Chunks                    Chunk Names
bundle.js  731 kB       0  [emitted]  [big]  main
  [40] ./node_modules/bindings 160 bytes {0} [optional] [built]
  [60] ./src/index.js 1.21 kB {0} [built]
    + 146 hidden modules

WARNING in ./node_modules/bindings/bindings.js
76:22-40 Critical dependency: the request of a dependency is an expression

WARNING in ./node_modules/bindings/bindings.js
76:43-53 Critical dependency: the request of a dependency is an expression
✨  Done in 1.93s.

and when I run the bundled code I get the following error. 当我运行捆绑的代码时,出现以下错误。

/Users/jakelacey/proj/ai/blankitv.0.0.1/dist/bundle.js:7860
    if (e.code !== 'MODULE_NOT_FOUND') throw e;
                                       ^

Error: Could not locate the bindings file. Tried:
 → /Users/jakelacey/proj/ai/blankitv.0.0.1/build/WebWorkerThreads.node
 → /Users/jakelacey/proj/ai/blankitv.0.0.1/build/Debug/WebWorkerThreads.node
 → /Users/jakelacey/proj/ai/blankitv.0.0.1/build/Release/WebWorkerThreads.node
 → /Users/jakelacey/proj/ai/blankitv.0.0.1/out/Debug/WebWorkerThreads.node
 → /Users/jakelacey/proj/ai/blankitv.0.0.1/Debug/WebWorkerThreads.node
 → /Users/jakelacey/proj/ai/blankitv.0.0.1/out/Release/WebWorkerThreads.node
 → /Users/jakelacey/proj/ai/blankitv.0.0.1/Release/WebWorkerThreads.node
 → /Users/jakelacey/proj/ai/blankitv.0.0.1/build/default/WebWorkerThreads.node
 → /Users/jakelacey/proj/ai/blankitv.0.0.1/compiled/7.2.1/darwin/x64/WebWorkerThreads.node
    at bindings (/Users/jakelacey/proj/ai/blankitv.0.0.1/dist/bundle.js:5488:9)
    at Object.<anonymous> (/Users/jakelacey/proj/ai/blankitv.0.0.1/dist/bundle.js:17414:47)
    at __webpack_require__ (/Users/jakelacey/proj/ai/blankitv.0.0.1/dist/bundle.js:20:30)
    at Object.webpackEmptyContext.keys (/Users/jakelacey/proj/ai/blankitv.0.0.1/dist/bundle.js:7857:19)
    at __webpack_require__ (/Users/jakelacey/proj/ai/blankitv.0.0.1/dist/bundle.js:20:30)
    at Object.<anonymous> (/Users/jakelacey/proj/ai/blankitv.0.0.1/dist/bundle.js:17360:18)
    at __webpack_require__ (/Users/jakelacey/proj/ai/blankitv.0.0.1/dist/bundle.js:20:30)
    at Object.<anonymous> (/Users/jakelacey/proj/ai/blankitv.0.0.1/dist/bundle.js:12097:27)
    at __webpack_require__ (/Users/jakelacey/proj/ai/blankitv.0.0.1/dist/bundle.js:20:30)
    at Object.<anonymous> (/Users/jakelacey/proj/ai/blankitv.0.0.1/dist/bundle.js:12000:66)

The code for the application is 该应用程序的代码是

var natural = require('natural');
var classifier = new natural.BayesClassifier();

// train.. 
classifier.addDocument('What is qqqq', ['question', 'unidentified']);
classifier.addDocument('can you give me an example of qqqq', ['example', 'maths', 'multiplicatication']);
classifier.addDocument('what is multiplication?', ['question', 'maths', 'multiplicatication']);
classifier.addDocument('addition', ['maths', 'addition']);
classifier.addDocument('division', ['maths', 'division']);

classifier.train();

console.log(classifier.classify('what is multiplication'));
console.log(classifier.classify('what is english'));
console.log(classifier.classify('what is english'));
console.log(classifier.classify('can you give me an example of multiplication'));

and the webpack configuration goes like so, Webpack的配置就像这样,

var path = require('path');
var FlowTypePlugin = require('flowtype-loader/plugin');

module.exports = {

  target: 'node',

  entry: './src/index.js',

  output: {
    filename: 'bundle.js',
    path: path.resolve(__dirname, 'dist')
  },

  module: {
    rules: [
      { 
        test: /\.js$/,
        exclude: /node_modules/,
        use: [
          {
            loader: 'flowtype-loader',
          },
          {
            loader: 'babel-loader',  
          }
        ]
      }
    ]
  },

  plugins: [
    new FlowTypePlugin()
  ]

}

Does anybody have a rough idea what is happening here? 有人粗略知道这里发生了什么吗? Thank you in advance. 先感谢您。

Did you get an error when running npm install (particularly when installing the native components of the package node-webworker-threads , which I think you are using) ? 在运行npm install时是否出现错误(尤其是在安装软件包node-webworker-threads的本机组件时,我认为您正在使用)? Do you have a native build tool chain (that includes a C compiler) installed for your development platform ? 您是否为开发平台安装了本机构建工具链(包括C编译器)?

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

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