Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/35.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/linux/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 无效的网页包配置对象_Node.js_Linux_Webpack - Fatal编程技术网

Node.js 无效的网页包配置对象

Node.js 无效的网页包配置对象,node.js,linux,webpack,Node.js,Linux,Webpack,我想访问这样的模块 var Builder = require('Builder'); 而不是 var Builder = require('./app/components/Builder'); 所以我生成了一个 webpack.config.js 文件使用 网页包版本1.12.13 这是我的档案 module.exports = { entry :'./app/app.jsx', output :{ path : __dirname, filename: './c

我想访问这样的模块

var Builder = require('Builder');
而不是

var Builder = require('./app/components/Builder');
所以我生成了一个

webpack.config.js

文件使用

网页包版本1.12.13

这是我的档案

module.exports =
{
  entry :'./app/app.jsx',
  output :{
    path : __dirname,
    filename: './client/bundle.js'
  },
  resolve :{
    root : __dirname,
    alias : {

    },
    extensions : ['.js','.jsx']
  },
  module :{
    loaders : [
      {
          loader :'babel-loader',
          query :{
            presets:['react','es2015']
          },
          test :/\.jsx?$/,
          exclude :/(node_modules|bower_components)/
      }
    ]
  }
}
一切都很好,直到我更新了我的

网页至3.5.4版

然后运行webpack,我在
解析对象中得到这个错误

Invalid configuration object. Webpack has been initialised using a configuration object that does not match the API schema.
 - configuration.resolve has an unknown property 'root'. These properties are valid:
   object { alias?, aliasFields?, cachePredicate?, cacheWithContext?, descriptionFiles?, enforceExtension?, enforceModuleExtension?, extensions?, fileSystem?, mainFields?, mainFiles?, moduleExtensions?, modules?, plugins?, resolver?, symlinks?, unsafeCache?, useSyncFileSystemCalls? }

问题是什么?我必须做出哪些改变

resolve.root不是有效的网页包配置属性

您所要做的就是从resolve对象中删除root

module.exports =
{
  entry :'./app/app.jsx',
  output :{
    path : __dirname,
    filename: './client/bundle.js'
  },
  resolve :{
    alias : {

    },
    extensions : ['.js','.jsx']
  },
  module :{
    loaders : [
      {
          loader :'babel-loader',
          query :{
            presets:['react','es2015']
          },
          test :/\.jsx?$/,
          exclude :/(node_modules|bower_components)/
      }
    ]
  }
}

有几种方法可以解析路径。path.resolve是单向的,您也可以使用别名。要做什么取决于你在应用程序编译时想要完成什么。非常感谢@thomasmeadows