Webpack:无法解析'undefined'或'null'的属性`curry`

问题描述 投票:0回答:2

在使用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;
...

所述代码来自依赖于ramdabluebird的私有函数库。该库在Node.js 8.9.1下使用和工作。

使用的webpack config直接来自philipwalton的webpack-esnext-boilerplate(很棒的开头:D)

Versions:

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

错误的来源是什么以及如何解决?

干杯✨

javascript node.js webpack babel babel-loader
2个回答
2
投票

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

如果要访问其他方法,可以使用此方法,例如:

import { curry, addIndex, clone } from 'ramda'


1
投票

如果您确实希望在一个对象中导出所有值,则可以执行以下操作

import * as R from 'ramda';
const { curry } = R;
© www.soinside.com 2019 - 2024. All rights reserved.