因为babel被转移到了babel-core

时间:2016-07-06 15:31:34

标签: node.js reactjs webpack

我已经按照不同开发人员发布的stackoverflow帖子的解决方案。但是,他们都没有帮助解决我遇到的问题。我做的事情很少是

  1. 卸载babel
  2. 安装babel-core,babel-cli
  3. 升级到节点v6.2.2
  4. 重新安装webpack
  5. 炸毁node_modules并再次运行npm install
  6. 以上所有内容从未修复此错误

    ERROR in The node API for `babel` has been moved to `babel-core`.
     @ (webpack)-dev-server/client?http://localhost:3333 1:10-24
    
    ERROR in The node API for `babel` has been moved to `babel-core`.
     @ (webpack)-dev-server/client?http://localhost:3333 3:16-37
    
    ERROR in The node API for `babel` has been moved to `babel-core`.
     @ (webpack)-dev-server/client?http://localhost:3333 2:13-37
    
    ERROR in (webpack)/~/process/browser.js
    Module build failed: Error: Couldn't find preset "react" relative to directory "/Users/admin/.nvm/versions/node/v6.0.0/lib/node_modules/webpack/node_modules/process"
        at /Users/admin/repos/ReactJSApps/react-es6-setup/node_modules/babel-core/lib/transformation/file/options/option-manager.js:395:17
        at Array.map (native)
    .
    .
    .
    webpack: bundle is now VALID.
    

    这是我的package.json

    {
      "name": "react-es6-setup",
      "version": "1.0.0",
      "description": "",
      "main": "index.js",
      "scripts": {
        "start": "webpack-dev-server"
      },
      "author": "",
      "license": "ISC",
      "dependencies": {
        "react": "^15.2.0",
        "react-dom": "^15.2.0"
      },
      "devDependencies": {
        "babel-core": "^6.10.4",
        "babel-loader": "^6.2.4",
        "babel-preset-es2015": "^6.9.0",
        "babel-preset-react": "^6.11.1"
      }
    }
    

    和webpack.config.js

    module.exports = {
      entry: './main.js',
      output: {
        path: './',
        filename: 'index.js'
      },
      devServer: {
        inline: true,
        port: 3333
      },
      module: {
        loaders: [
            {
              test: /\.js$/,
              exclude: 'node_modules',
              loader: 'babel',
              query: {
                presets: [ 'es2015', 'react' ]
              }
            }
        ]
      }
    }
    

    和node_modules的目录列表

    $ ls -l node_modules/ |grep react
    drwxr-xr-x    6 admim  207825898    204 Jul  6 02:02 babel-helper-builder-react-jsx/
    drwxr-xr-x    6 admim  207825898    204 Jul  6 02:02 babel-plugin-transform-react-display-name/
    drwxr-xr-x    6 admim  207825898    204 Jul  6 02:02 babel-plugin-transform-react-jsx/
    drwxr-xr-x    6 admim  207825898    204 Jul  6 02:02 babel-plugin-transform-react-jsx-self/
    drwxr-xr-x    6 admim  207825898    204 Jul  6 02:02 babel-plugin-transform-react-jsx-source/
    drwxr-xr-x    6 admim  207825898    204 Jul  6 02:02 babel-preset-react/
    drwxr-xr-x    9 admim  207825898    306 Jul  6 02:03 react/
    drwxr-xr-x    9 admim  207825898    306 Jul  6 02:03 react-dom/
    

3 个答案:

答案 0 :(得分:7)

new_df.index.rename(['chrom','strand','abs_pos'], inplace=True) new_df.set_index('gene', append=True) new_df A B C chrom strand abs_pos gene chrom1 - 1234 geneA 1 1 1 + 5678 geneB 2 2 2 9876 geneC 3 3 3 chrom2 + 13579 geneD 4 4 4 8497 geneE 5 5 5 - 98765 geneF 6 6 6 76856 geneG 7 7 7 loaders: 'babel-loader'为我解决问题 -

使用npm

安装这些依赖项
webpack.config.js

"babel-core": "^6.1.2", "babel-loader": "^6.1.0", "babel-plugin-transform-runtime": "^6.1.2", "babel-preset-es2015": "^6.1.2", "babel-preset-stage-0": "^6.1.2", "babel-runtime": "^5.8.0", 文件中,请输入以下代码:

webpack.config.js

答案 1 :(得分:0)

试试这个:

首先删除.next { bottom: 35px; } 文件夹,然后删除

section {
  height:calc(100vh - 34px);
}

确保您的webpack.config.js具有:

node_module

然后npm init npm i webpack -S (Install Globally too) npm i babel-loader babel-preset-es2015 babel-preset-react babel-core -S npm i react react-dom -S`

答案 2 :(得分:0)

我通过在Webpack配置中将加载程序更改为babel-loader而不是babel来解决此问题。

module: {
    rules: [
        {
            ...
            loader: 'babel',
            ...
        },
    ],
},