“unexpected token import” in Nodejs5 and babel?

前端 未结 13 2164
清酒与你
清酒与你 2020-11-30 18:40

In js file, i used import to instead of require

import co from \'co\';

And tried to run it directly by nodejs since it said import is \'shi

13条回答
  •  余生分开走
    2020-11-30 19:16

    if you use the preset for react-native it accepts the import

    npm i babel-preset-react-native --save-dev
    

    and put it inside your .babelrc file

    {
      "presets": ["react-native"]
    }
    

    in your project root directory

    https://www.npmjs.com/package/babel-preset-react-native

提交回复
热议问题