简体   繁体   English

node_modules \\ ng2-dragula \\ index.js不会导出'DragulaModule'

[英]'DragulaModule' is not exported by node_modules\ng2-dragula\index.js

'DragulaModule' is not exported by node_modules\ng2-dragula\index.js
https://github.com/rollup/rollup/wiki/Troubleshooting#name-is-not-exported-by-module
app\app.module.js (13:9)
11: import { BrowserModule } from '@angular/platform-browser';
12: import { AppComponent } from './app.component';
13: import { DragulaModule } from 'ng2-dragula';
             ^
14: import { FileUploadModule } from "ng2-file-upload";

rollup.config.js rollup.config.js

import rollup      from 'rollup'
import nodeResolve from 'rollup-plugin-node-resolve'
import commonjs    from 'rollup-plugin-commonjs';
import uglify      from 'rollup-plugin-uglify';

export default {
  entry: 'app/main.js',
  dest: 'dist/build.js',
  sourceMap: false,
  format: 'iife',
  plugins: [
      nodeResolve({jsnext: true, module: true}),
      commonjs({
        include: 'node_modules/rxjs/**',
      }),
      uglify()
  ]
}

Using Rollup for tree-shaking and build gives me the above error after successfully generating files with aot. 在使用aot成功生成文件后,使用汇总进行树状摇晃和构建会出现上述错误。 Any suggestion is highly appreciated. 任何建议都将受到高度赞赏。

Try add a named export in your rollup.config 尝试在您的rollup.config中添加一个命名的导出

 commonjs({ include: 'node_modules/rxjs/**', namedExports: { 'node_modules/ng2-dragula/ng2-dragula.js': [ 'DragulaModule', 'DragulaService' ] } }) 

You can read more about custom named exports here: https://github.com/rollup/rollup-plugin-commonjs#custom-named-exports 您可以在此处阅读有关自定义命名导出的更多信息: https : //github.com/rollup/rollup-plugin-commonjs#custom-named-exports

if ur using angular 6 如果您使用角度6
adding this line in to pollyfills.ts fixed my problem 将此行添加到pollyfills.ts中解决了我的问题

(window as any).global = window; (任意窗口).global = window;

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 汇总错误:node_modules/react/index.js 未导出“默认” - Rollup Error: 'default' is not exported by node_modules/react/index.js 从 node_modules index.js 导入 class 定义 - import class definitions from node_modules index.js Svelte Cognito RollupJs 错误:node_modules/@aws-crypto/sha256-js/build/index.js 未导出“Sha256” - Svelte Cognito RollupJs error: 'Sha256' is not exported by node_modules/@aws-crypto/sha256-js/build/index.js Jest js node_modules\\jest\\node_modules\\jest-cli\\build\\cli\\index.js:227 } catch { - Jest js node_modules\jest\node_modules\jest-cli\build\cli\index.js:227 } catch { 错误 in./src/index.js 模块构建失败(来自./node_modules/babel-loader/lib/index.js): - ERROR in ./src/index.js Module build failed (from ./node_modules/babel-loader/lib/index.js): Nuxt.js:模块错误(来自./node_modules/eslint-loader/index.js): - Nuxt.js: Module Error (from ./node_modules/eslint-loader/index.js): 模块构建失败(来自 ./node_modules/babel-loader/lib/index.js)Vue Js - Module build failed (from ./node_modules/babel-loader/lib/index.js) Vue Js Webpack:node_modules / css / index.js没有返回函数 - Webpack: node_modules/css/index.js didn't return a function 未捕获的错误:模块构建失败(来自./node_modules/babel-loader/lib/index.js) - Uncaught Error: Module build failed (from ./node_modules/babel-loader/lib/index.js) Webpack css 加载器问题“!!../../node_modules/css-loader/index.js!./main.css” - Webpack css loader issues "!!../../node_modules/css-loader/index.js!./main.css"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM