RollupJS`解析失败:错误:无法找到模块' babel-runtime'`

时间:2016-12-14 15:40:59

标签: node.js npm babeljs rollupjs

汇总误差-示例

用汇总说明(可能的)问题。

我错过了什么吗?这是一个具有最小配置的项目 重现"问题"我遇到了。问题似乎只是无关紧要 命令行日志记录而不影响bundle本身;即捆绑是 正确而准确地创建。

此项目显示输出:

$ ./node_modules/.bin/rollup -c rollup.js
node_modules/nan
resolve failed:  { Error: Cannot find module 'babel-runtime'
    at Function.Module._resolveFilename (module.js:472:15)
    at Function.requireRelative.resolve (/Users/jkalis/Pro/QL/WebCore/luxui/rollup-testing/node_modules/require-relative/index.js:30:17)
    at resolve (/Users/jkalis/Pro/QL/WebCore/luxui/rollup-testing/node_modules/modify-babel-preset/lib/serialize.js:25:26)
    at findAndRemove (/Users/jkalis/Pro/QL/WebCore/luxui/rollup-testing/node_modules/modify-babel-preset/lib/serialize.js:67:11)
    at /Users/jkalis/Pro/QL/WebCore/luxui/rollup-testing/node_modules/modify-babel-preset/lib/serialize.js:111:13
    at Array.map (native)
    at loadPreset (/Users/jkalis/Pro/QL/WebCore/luxui/rollup-testing/node_modules/modify-babel-preset/lib/serialize.js:103:29)
    at module.exports (/Users/jkalis/Pro/QL/WebCore/luxui/rollup-testing/node_modules/modify-babel-preset/index.js:97:19)
    at Object.<anonymous> (/Users/jkalis/Pro/QL/WebCore/luxui/rollup-testing/node_modules/babel-preset-es2015-rollup/index.js:3:18)
    at Module._compile (module.js:573:32) code: 'MODULE_NOT_FOUND' } babel-runtime

重现此命令的命令是:

  • npm run bundle
  • ./node_modules/.bin/rollup -c rollup.js

在其他项目中,我遇到类似的问题,还有其他解决方案&#34;失败&#34;那 似乎不会影响捆绑本身。这是否易于解决?

我创建了一个Git存储库 - https://github.com/kalisjoshua/rollup-error-example - 它表现出这种行为。

我错过了什么?

1 个答案:

答案 0 :(得分:8)

显示如何重现错误的github上的repo显示正在使用的版本1.2.0的babel-preset-es2015-rollup。我在github上找到了以下内容:

看起来babel-preset-es2015-rollup软件包只需更新到最新版本,因为在我尝试之后,错误不再出现。

diff --git a/package.json b/package.json
index b1f4325..d5251fd 100644
--- a/package.json
+++ b/package.json
@@ -12,7 +12,7 @@
   "license": "MIT",
   "dependencies": {
     "babel-cli": "^6.18.0",
-    "babel-preset-es2015-rollup": "^1.2.0",
+    "babel-preset-es2015-rollup": "^3.0.0",
     "rollup": "^0.36.4",
     "rollup-plugin-babel": "^2.6.1"
   }