javascript - Webpack:无法解构 `curry` 或 'undefined' 的属性 'null'

标签 javascript node.js webpack babeljs babel-loader

在浏览器中使用 webpack 和 babel-loader 编译我的应用程序后,在主函数开始之前立即出现以下错误:

Uncaught TypeError: Cannot destructure property `curry` of 'undefined' or 'null'.
    at Object../node_modules/@qzdio/f/lib/combinators/sync.js (index-c1596672f4.js:formatted:268)
    at n (runtime-74c3f0da77.js:formatted:10)
    at Object../node_modules/@qzdio/f/lib/combinators/index.js (index-c1596672f4.js:formatted:251)
    at n (runtime-74c3f0da77.js:formatted:10)
    at Object../node_modules/@qzdio/f/lib/index.js (index-c1596672f4.js:formatted:723)
    at n (runtime-74c3f0da77.js:formatted:10)
    at Object../dist/graph/visualizer/src/index.js (index-c1596672f4.js:formatted:9)
    at n (runtime-74c3f0da77.js:formatted:10)
    at window.webpackJsonp (runtime-74c3f0da77.js:formatted:26)
    at index-c1596672f4.js:formatted:1

错误代码是以下内容的 ES5 转译:

import R from 'ramda';
const { curry } = R;

// I :: a -> a
const I = (x) => x;
...

其中所述代码来自依赖于 ramda 的私有(private)函数库。和 bluebird 。该库在 Node.js 8.9.1 下使用和运行。

webpack config使用的是直接来自 philipwalton 的 webpack-esnext-boilerplate (很好的开始:D)

版本:

  • babel-cli:^6.26.0,
  • babel-loader:^7.1.2,
  • webpack:^3.8.1,
  • 浏览器:Google Chrome 版本 62.0.3202.89(官方版本)(64 位),
  • Node.js:8.9.1,
  • npm:5.5.1

错误的根源是什么?如何解决?

干杯✨

最佳答案

您必须使用import { curry } from 'ramda'。您可以看到here rambda 如何导出它的模块。它不会导出 ramda 模块本身,而是导出各个函数。

如果您想访问其他方法,您可以使用以下方法:

从 'ramda' 导入 { curry, addIndex, clone }

关于javascript - Webpack:无法解构 `curry` 或 'undefined' 的属性 'null',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47333634/

相关文章:

javascript - 如何将 POST 请求的结果传递到 Ionic 和 Angular 中的另一个页面

node.js - 首先使用Node和pg创建数据库后如何创建表

javascript - 如何在休息时禁用管理中的每页限制?

javascript - 意外的 token '<' React Webpack 构建

javascript - TS7016 : TypeScript don't see plain . js文件

javascript - 搜索过滤器列表,无论词序如何,搜索严格性问题

javascript - 带有指向其他页面的链接的 jQuery 单页滚动

javascript - 如何使用 es6 语法导入 ReactCSSTransitionGroup?

javascript - AppJS 拖放事件从未触发

node.js - 防止 Node 在内存不足时崩溃