【发布时间】:2017-04-01 19:35:39
【问题描述】:
我刚刚开始涉足 React,我想要的第一个组件之一是使用 photoswipe.js。 (react photoswipe) 看起来 npm 上有一个相当不错的,但我遇到了问题。当我运行我的故事书开始测试和构建我的组件时,我从 babel 收到一个错误。它说:
in ./~/react-photoswipe/lib/index.js
Module build failed: ReferenceError: [BABEL] C:\Code\GIT\DanStatenReact\DanStatenUI\node_modules\react-photoswipe\lib\index.js: Using removed Babel 5 option: C:\Code\GIT\DanStatenReact\DanStatenUI\node_modules\react-photoswipe\.babelrc.stage - Check out the corresponding stage-x presets http://babeljs.io/docs/plugins/#presets
at Logger.error (C:\Code\GIT\DanStatenReact\DanStatenUI\node_modules\babel-core\lib\transformation\file\logger.js:41:11)
at OptionManager.mergeOptions (C:\Code\GIT\DanStatenReact\DanStatenUI\node_modules\babel-core\lib\transformation\file\options\option-manager.js:220:20)
at OptionManager.init (C:\Code\GIT\DanStatenReact\DanStatenUI\node_modules\babel-core\lib\transformation\file\options\option-manager.js:368:12)
at File.initOptions (C:\Code\GIT\DanStatenReact\DanStatenUI\node_modules\babel-core\lib\transformation\file\index.js:212:65)
at new File (C:\Code\GIT\DanStatenReact\DanStatenUI\node_modules\babel-core\lib\transformation\file\index.js:135:24)
at Pipeline.transform (C:\Code\GIT\DanStatenReact\DanStatenUI\node_modules\babel-core\lib\transformation\pipeline.js:46:16)
at transpile (C:\Code\GIT\DanStatenReact\DanStatenUI\node_modules\babel-loader\lib\index.js:46:20)
at C:\Code\GIT\DanStatenReact\DanStatenUI\node_modules\babel-loader\lib\fs-cache.js:79:18
at ReadFileContext.callback (C:\Code\GIT\DanStatenReact\DanStatenUI\node_modules\babel-loader\lib\fs-cache.js:15:14)
at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:365:13)
所以我四处摸索了一下,发现 babel rc 文件似乎设置为 stage:0,据我了解,如果您生产的组件应该像javascript 规范更新和发展。
虽然我对使用 babel 还是很陌生,所以我很难跟踪我需要为这个组件更新什么,才能让它在我的环境中使用较新的 babel 工作。有没有人遇到过这个组件的这个问题?有没有人对如何解决 bable transpile 并追踪我需要更新的内容有任何建议或提示?
【问题讨论】:
标签: reactjs webpack babeljs photoswipe