升级到nodejs 0.10.0和npm 1.2.14之后,如果我尝试创建一个webapp,则yeoman 1.0 beta会失败:
$ yo webapp
path.js:360
throw new TypeError('Arguments to path.join must be strings');
^
TypeError: Arguments to path.join must be strings
at path.js:360:15
at Array.filter (native)
at Object.exports.join (path.js:358:36)
at Object.<anonymous> (/opt/nodejs/node-v0.10.0-linux-x64/lib/node_modules/yo/node_modules/yeoman-generator/node_modules/bower/lib/core/config.js:41:22)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
Run Code Online (Sandbox Code Playgroud)
节点安装在/opt/nodejs/node-v0.10.0-linux-x64.该NODE_PATH环境变量指向的路径:
$ echo $NODE_PATH
/opt/nodejs/node-v0.10.0-linux-x64
Run Code Online (Sandbox Code Playgroud)
即使yo init失败也会出现同样的错误.
有什么建议在这里出错吗?
在进行一些练习时,我提出了一个(可能)不是惯用的解决方案,它可以完美地编译但是没有按预期运行?
def span(xs, min, max), do: _span(xs,min,max)
defp _span([], _, _), do: []
# The following guard does not match
defp _span([head | tail],min,max) when min <= head <= max, do: [head | _span(tail,min,max)]
defp _span([head | tail],min,max), do: _span(tail,min,max)
Run Code Online (Sandbox Code Playgroud)
问题是为什么编译但不起作用?
顺便说一句.我知道'更多'类似于灵药的解决方案可能就是这个(至少它可以完成这项工作):
defp _span([head | tail],min,max) when head in min..max, do: [head | _span(tail,min,max)]
Run Code Online (Sandbox Code Playgroud)
谢谢.