babel + path + node 6.x:TypeError:Path必须是一个字符串。收到undefined

时间:2016-06-13 06:48:23

标签: node.js babeljs

我一直在尝试将我的nodejs版本更新为6.x,但每次都会出现以下错误:

path.js:7
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received undefined
    at assertPath (path.js:7:11)
    at Object.dirname (path.js:1326:5)
    at /usr/lib/node_modules/babel-core/lib/transformation/file/options/option-manager.js:374:36
    at /usr/lib/node_modules/babel-core/lib/transformation/file/options/option-manager.js:396:22
    at Array.map (native)
    at OptionManager.resolvePresets (/usr/lib/node_modules/babel-core/lib/transformation/file/options/option-manager.js:385:20)
    at OptionManager.mergePresets (/usr/lib/node_modules/babel-core/lib/transformation/file/options/option-manager.js:369:10)
    at OptionManager.mergeOptions (/usr/lib/node_modules/babel-core/lib/transformation/file/options/option-manager.js:328:14)
    at /usr/lib/node_modules/babel-core/lib/transformation/file/options/option-manager.js:370:14
    at /usr/lib/node_modules/babel-core/lib/transformation/file/options/option-manager.js:390:24

我试过这三个版本:

  • 的NodeJS-6.0.0-1
  • 的NodeJS-6.2.0-1
  • 的NodeJS-6.2.1-1
package.json中的

"babel-core": "^6.9.1"

我完全不知道从哪里开始寻找调试。有人有建议吗? :)更多信息会相关吗?让我知道!

提前致谢!

2 个答案:

答案 0 :(得分:5)

该问题与Node 6有关。使用Node 5.x可能会为您解决问题,如果这是一个选项。

最简单的方法是install Node Version Manageror a port for Windows),然后运行以下命令:

nvm install 5
nvm use 5

如果要将5.x用作默认节点版本,请运行以下命令:

nvm alias default 5

答案 1 :(得分:5)

将babel-core升级到6.10.4 ..