Error: Couldn't find preset “react” when installed using npm install --global babel-preset-react but works without global flag

后端 未结 2 1324
逝去的感伤
逝去的感伤 2021-01-01 18:25

I installed Babel CLI (version 6) using npm install --global babel-cli. I then install react preset using npm install --global babel-preset-react.

2条回答
  •  醉酒成梦
    2021-01-01 19:09

    You can specify the absolute (or relative) path to the preset you are trying to use, e.g:

    babel --presets /usr/local/lib/node_modules/babel-preset-react --watch jsx/ --out-dir js/
    

提交回复
热议问题