我已经安装了Bower,但是遇到了这些错误,请问你有什么办法吗?
[noor@laptop03 ~]$ bower
/usr/local/lib/node_modules/bower/node_modules/bower-config/lib/util/rc.js:55
throw error;
^
我已经安装了Bower,但是遇到了这些错误,请问你有什么办法吗?
[noor@laptop03 ~]$ bower
/usr/local/lib/node_modules/bower/node_modules/bower-config/lib/util/rc.js:55
throw error;
^
昨天我遇到了同样的问题。如果您的完整错误日志就是这个:
/usr/local/lib/node_modules/bower/node_modules/bower-config/lib/util/rc.js:55
throw error;
^
Error: Unable to parse /vagrant/web/.bowerrc: Unexpected token d
at parse (/usr/local/lib/node_modules/bower/node_modules/bower-config/lib/util/rc.js:48:21)
at json (/usr/local/lib/node_modules/bower/node_modules/bower-config/lib/util/rc.js:70:12)
at rc (/usr/local/lib/node_modules/bower/node_modules/bower-config/lib/util/rc.js:31:9)
at Config.load (/usr/local/lib/node_modules/bower/node_modules/bower-config/lib/Config.js:14:20)
at Function.Config.read (/usr/local/lib/node_modules/bower/node_modules/bower-config/lib/Config.js:49:19)
at Object.<anonymous> (/usr/local/lib/node_modules/bower/lib/config.js:3:38)
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)
那么你的 .bowerrc 文件可能缺少引号。我曾经遇到过这个问题:
{
directory: "app/Resources/public/vendor"
}
更改为以下内容并使其正常工作:
{
"directory": "app/Resources/public/vendor"
}
如果您仍然遇到意外令牌的其他错误,请检查您的bower.json文件,确保键和值周围有引号。
一个有效的bower.json示例:
{
"name": "project",
"version": "0.0.0",
"license": "MIT",
"private": true,
"ignore": [
"**/.*",
"node_modules",
"bower_components",
"test",
"tests"
],
"dependencies": {
"jquery": "~2.0.3",
"underscore": "~1.5.2"
}
}