错误:找不到绑定文件。尝试:( Webpack)

时间:2017-06-23 15:47:58

标签: javascript node.js webpack ecmascript-6

当我使用webpack捆绑代码时,我创建了一个使用npm包natural的小项目,我收到了这些警告。

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.

当我运行捆绑代码时,我收到以下错误。

/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)

该应用程序的代码是

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'));

并且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()
  ]

}

有没有人大致了解这里发生了什么?提前谢谢。

1 个答案:

答案 0 :(得分:0)

运行npm install时是否出现错误(特别是在安装包node-webworker-threads的本机组件时,我认为您正在使用)?您是否为开发平台安装了本机构建工具链(包括C编译器)?