import a module from node_modules with babel but failed

后端 未结 3 1312
庸人自扰
庸人自扰 2020-12-03 14:04

I wrote a module with es6 and publish to the npm, I want to use it in another project, so I type like this:

import {ActionButton} from \'rcomponents\'
         


        
3条回答
  •  既然无缘
    2020-12-03 14:37

    You can use https://www.npmjs.com/package/babel-node-modules for this case

    npm install --save-dev babel-node-modules
    require('babel-node-modules')([
      'helloworld' // add an array of module names here 
    ]);
    

    and then it compiles listed modules as other files

提交回复
热议问题