0

我需要redux-form-3.0.8并从 github下载了源代码。

我试图执行' npm run build '来编译它,但出现以下错误。

C:\Users\xxxxx\Downloads\redux-form-3.0.8\redux-form-3.0.8>npm run build

> redux-form@3.0.8 build C:\Users\xxxxx\Downloads\redux-form-3.0.8\redux-form-
3.0.8
> npm run build:lib && npm run build:umd && npm run build:umd:min


> redux-form@3.0.8 build:lib C:\Users\xxxxx\Downloads\redux-form-3.0.8\redux-f
orm-3.0.8
> babel src --out-dir lib

ReferenceError: [BABEL] src\actions.js: Unknown option: C:\Users\xxxxx\Downloa
ds\redux-form-3.0.8\redux-form-3.0.8\.babelrc.stage
    at Logger.error (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\babel-cli
\node_modules\babel-core\lib\transformation\file\logger.js:41:11)
    at OptionManager.mergeOptions (C:\Users\xxxxx\AppData\Roaming\npm\node_mod
ules\babel-cli\node_modules\babel-core\lib\transformation\file\options\option-ma
nager.js:262:18)
    at OptionManager.addConfig (C:\Users\xxxxx\AppData\Roaming\npm\node_module
s\babel-cli\node_modules\babel-core\lib\transformation\file\options\option-manag
er.js:221:10)
    at OptionManager.findConfigs (C:\Users\xxxxx\AppData\Roaming\npm\node_modu
les\babel-cli\node_modules\babel-core\lib\transformation\file\options\option-man
ager.js:364:16)
    at OptionManager.init (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\bab
el-cli\node_modules\babel-core\lib\transformation\file\options\option-manager.js
:412:12)
    at File.initOptions (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\babel
-cli\node_modules\babel-core\lib\transformation\file\index.js:190:75)
    at new File (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\babel-cli\nod
e_modules\babel-core\lib\transformation\file\index.js:121:22)
    at Pipeline.transform (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\bab
el-cli\node_modules\babel-core\lib\transformation\pipeline.js:42:16)
    at transform (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\babel-cli\li
b\babel\util.js:53:22)
    at Object.compile (C:\Users\xxxxx\AppData\Roaming\npm\node_modules\babel-c
li\lib\babel\util.js:62:12)

我发现' npm run build ' 将首先在package.json中调用' babel src --out-dir lib ' 。所以这个错误是由babel命令抛出的。

下面是我的 babel 版本。C:\Users\xxxxxx\node_modules\redux-form> babel --version 6.2.0 (babel-core 6.2.1)

你能告诉我如何绕过这个问题吗?谢谢。

我知道我可以像下面这样直接安装编译版本,但它仍然出错,我很沮丧。

C:\Users\xxxxx\node_modules>npm install redux-form@3.0.8
npm WARN checkPermissions Missing write access to C:\Users\xxxxx\node_modules\
redux-form
gulp@3.9.0 C:\Users\xxxxx
├── UNMET PEER DEPENDENCY babel-core@*
├── UNMET PEER DEPENDENCY react-redux@^3.0.0 || ^4.0.0
├── redux-form@3.0.8  extraneous
└── UNMET PEER DEPENDENCY webpack@*

npm WARN EPEERINVALID babel-loader@5.3.2 requires a peer of babel-core@* but non
e was installed.
npm WARN EPEERINVALID babel-loader@5.3.2 requires a peer of webpack@* but none w
as installed.
npm WARN EPEERINVALID redux-form@3.0.8 requires a peer of react-redux@^3.0.0 ||
^4.0.0 but none was installed.
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\xxxxx\\AppData
\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "install" "redux-form@3.0.8"

npm ERR! node v4.1.1
npm ERR! npm  v3.3.6
npm ERR! path C:\Users\xxxxx\node_modules\redux-form
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall access

npm ERR! enoent ENOENT: no such file or directory, access 'C:\Users\xxxxx\node
_modules\redux-form'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\xxxxx\node_modules\npm-debug.log
4

1 回答 1

2

因为 babel 6 不兼容旧的 .babelrc

以下是一些解决方案:

  1. 尝试删除所有 .babelrc 并将选项添加到您的 webpack config.js
  2. 使用通天塔 5

参考: https ://github.com/babel/babel-loader/issues/132

于 2016-02-17T07:29:31.000 回答