[英]Failed to export function properly, es6
所以上次我检查了我做的一切是否正确,但是我需要另一双眼睛:
转换锁文件.js
import yaml from 'yamljs';
export function convertYarnLockToJSON() {
yaml.load(__dirname + yarn.lock', (result) => {
console.log(result); // eslint-disable-line
});
}
fetching-data.js
import convertYarnLockToJSON from '../lib/convert-lock-file';
// else where in the code:
convertYarnLockToJSON();
错误:
Uncaught TypeError: (0 , _convertLockFile2.default) is not a function
当我这样做时: console.log(convertYarnLockToJSON)
我得到了undefined
。
我是盲人,过度疲劳还是不对劲。 我正在使用webpack和babel进行编译,以防万一。 有想法吗?
我认为您需要将功能export default
为export default
。
或者,您可以:
import { convertYarnLockToJSON } from '../lib/convert-lock-file';
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.