首页 > 解决方案 > 使用 ng-packagr/angular 构建时出错

问题描述

我正在使用 Angular 7 并使用 ng-packagr 构建一个库。

升级到最新版本的 ng-packagr 和 lodash 后,我收到此错误

ERROR: 'isString' is not exported by node_modules\lodash\lodash.js
'isString' is not exported by node_modules\lodash\lodash.js
Error: 'isString' is not exported by node_modules\lodash\lodash.js
    at error (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:9419:30)
    at Module.error (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:13402:9)
    at handleMissingExport (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:13322:21)
    at Module.traceVariable (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:13711:17)
    at ModuleScope.findVariable (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:12414:39)
    at FunctionScope.findVariable (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:2981:38)
    at ChildScope.findVariable (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:2981:38)
    at FunctionScope.findVariable (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:2981:38)
    at ChildScope.findVariable (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:2981:38)
    at Identifier$1.bind (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:8340:40)
    at CallExpression$1.bind (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:7969:23)
    at CallExpression$1.bind (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:10361:15)
    at LogicalExpression.bind (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:7969:23)
    at LogicalExpression.bind (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:11150:15)
    at ReturnStatement$1.bind (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:7969:23)
    at BlockStatement$1.bind (C:\Users\me\myapp\node_modules\rollup\dist\rollup.js:7965:31)

知道如何解决吗?

标签: angularrollupjsng-packagr

解决方案


对我有用的是替换

import { isString } from "lodash";

import { isString } from "lodash-es";

推荐阅读