网站搜索

javascript - Angular 7 项目无法导入 node-vibrant


我正在尝试将 node-vibrant 导入到我的 Angular 7 项目中,但遇到了一些问题:

-我可以使用 import * as Vibrant from 'node-vibrant'; 导入它,但我在 VS Code 中收到以下警告:

Module '"/Users/xxxx/Documents/dev/x/node_modules/node-vibrant/lib/index"' resolves to a non-module entity and cannot be imported using this construct

该应用在开发中可以正常实时重载,但当我尝试构建时,上述错误变得致命,无法构建。

-我可以使用 import * as Vibrant from 'node-vibrant'; 导入它,但我会收到以下警告(再次说明,在开发环境下实时重载是正常的):当目标为 ECMAScript 模块时,不能使用导入赋值。请考虑使用 'import * as ns from "mod"'、'import {a} from "mod"'、'import d from "mod"' 或其他模块格式。

在构建时,这个错误也会变得致命。

我现在无法构建,因为没有任何方法可以导入这个文件。对此有合理的解决办法吗?

答案#1

在 Angular 7 中,在方法或函数中要求使用 vibrant 对我来说似乎有效。

const vibrant = require('node-vibrant');

然而,现在出现了这个问题:https://github.com/akfish/node-vibrant/issues/85