bower安装最终会出现错误:无法调用null的方法'split'

时间:2013-07-28 20:04:27

标签: javascript npm bower

我的component.json文件:

{
  "name": "my-project",
  "version": "1.0.0",
  "main": "path/to/main.css",
  "dependencies": {
    "jquery": null
  }
}

我跑的时候 $ bower install

我明白了:

bower error无法调用null的方法'split'

Stack trace:
TypeError: Cannot call method 'split' of null
    at Object.json2decomposed (/usr/local/lib/node_modules/bower/node_modules/bower-endpoint-parser/index.js:40:23)
    at Project._restoreNode (/usr/local/lib/node_modules/bower/lib/core/Project.js:704:35)
    at /usr/local/lib/node_modules/bower/node_modules/mout/object/forOwn.js:12:27
    at exec (/usr/local/lib/node_modules/bower/node_modules/mout/object/forIn.js:57:19)
    at forIn (/usr/local/lib/node_modules/bower/node_modules/mout/object/forIn.js:38:17)
    at Object.forOwn (/usr/local/lib/node_modules/bower/node_modules/mout/object/forOwn.js:10:9)
    at Project._restoreNode (/usr/local/lib/node_modules/bower/lib/core/Project.js:702:17)
    at Project._analyse (/usr/local/lib/node_modules/bower/lib/core/Project.js:446:14)
    at Q.async (/usr/local/lib/node_modules/bower/node_modules/q/q.js:1126:30)
    at _fulfilled (/usr/local/lib/node_modules/bower/node_modules/q/q.js:703:54)

1 个答案:

答案 0 :(得分:1)

null不是依赖项的有效值。您必须指定一个版本。

"dependencies": {
  "jquery": "1.10.2"
}

指定semver Range

可以是近似值
"jquery": "~1.10"
"jquery": "1.10.x"

或者,它可以设置为"latest",目前将安装2.0.3

"jquery": "latest"