0

我正在尝试将 grunt-phantomcss 安装到我的应用程序,但出现以下错误:

C:\test>npm install grunt-phantomcss --save-dev
npm WARN package.json cgmbase@0.0.0 No repository field.
|
> grunt-phantomcss@0.2.3 postinstall C:\test\node_modules\grunt-phantom
css
> node ./node_modules/bower/bin/bower install

bower not-cached    git://github.com/Huddle/PhantomCSS.git#f0846511d9e1e55aa160a
aab84e2a150bd3a5a41
bower resolve       git://github.com/Huddle/PhantomCSS.git#f0846511d9e1e55aa160a
aab84e2a150bd3a5a41
bower checkout      phantomcss#f0846511d9e1e55aa160aaab84e2a150bd3a5a41
bower error         Arguments to path.join must be strings

Stack trace:
TypeError: Arguments to path.join must be strings
    at f (path.js:204:15)
    at Object.filter (native)
    at Object.exports.join (path.js:209:40)
    at GitHubResolver.GitResolver._cleanup (C:\test\node_modules\grunt-
phantomcss\node_modules\bower\lib\core\resolvers\GitResolver.js:158:26)
    at C:\test\node_modules\grunt-phantomcss\node_modules\bower\lib\cor
e\resolvers\GitResolver.js:66:25
    at Promise.apply (C:\test\node_modules\q\q.js:1122:26)
    at Promise.promise.promiseDispatch (C:\test\node_modules\q\q.js:752
:41)
    at C:\test\node_modules\q\q.js:1337:14
    at flush (C:\test\node_modules\q\q.js:108:17)
    at process._tickCallback (node.js:419:13)

Console trace:
Trace
    at StandardRenderer.error (C:\test\node_modules\grunt-phantomcss\no
de_modules\bower\lib\renderers\StandardRenderer.js:69:17)
    at Logger.updateNotifier.packageName (C:\test\node_modules\grunt-ph
antomcss\node_modules\bower\bin\bower:113:18)
    at Logger.emit (events.js:95:17)
    at Logger.emit (C:\test\node_modules\grunt-phantomcss\node_modules\
bower\node_modules\bower-logger\lib\Logger.js:29:39)
    at C:\test\node_modules\grunt-phantomcss\node_modules\bower\lib\com
mands\install.js:25:16
    at _rejected (C:\test\node_modules\q\q.js:808:24)
    at C:\test\node_modules\q\q.js:834:30
    at Promise.when (C:\test\node_modules\q\q.js:1079:31)
    at Promise.promise.promiseDispatch (C:\test\node_modules\q\q.js:752
:41)
    at C:\test\node_modules\q\q.js:574:44

System info:
Bower version: 1.0.3
Node version: 0.10.32
OS: Windows_NT 6.1.7601 x64

npm ERR! grunt-phantomcss@0.2.3 postinstall: `node ./node_modules/bower/bin/bowe
r install`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the grunt-phantomcss@0.2.3 postinstall script.
npm ERR! This is most likely a problem with the grunt-phantomcss package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node ./node_modules/bower/bin/bower install
npm ERR! You can get their info via:
npm ERR!     npm owner ls grunt-phantomcss
npm ERR! There is likely additional logging output above.
npm ERR! System Windows_NT 6.1.7601
npm ERR! command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nod
ejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "grunt-phantomcss" "--save-de
v"
npm ERR! cwd C:\test
npm ERR! node -v v0.10.32
npm ERR! npm -v 1.4.28
npm ERR! code ELIFECYCLE
npm ERR! not ok code 0

有谁知道我能做些什么来解决这个问题?我试图清理 bower 和 npm 缓存,但我得到了同样的错误。

4

1 回答 1

0

您可以使用 npm shrinkwrap功能来覆盖 grunt-phantomcss 使用的 bower 版本。
npm-shrinkwrap 锁定包依赖项的版本,以便您可以准确控制安装包时将使用每个依赖项的哪些版本。

在您的情况下,您应该从当前的 package.json 文件创建一个 npm-shrinkwrap.json,然后覆盖 grunt-phantomcss 使用的 bower 版本:

{
  "name": "my-app",
  "version": "0.0.0",
  "dependencies": {
    "grunt-phantomcss": {
      "version": "0.2.3",
      "from": "grunt-phantomcss@0.2.3",
      "dependencies": {
        "bower": {
          "version": "1.3.12",
          "from": "bower@~1.3.12"
        }
      }
    }
  }
}

请注意,此示例仅包含 grunt-phantomcss 的相关部分。您应该使用的实际文件必须包含所有其他依赖项。

于 2014-11-17T22:29:42.860 回答