Bower - error when installing package “Arguments to path.join must be strings”

好久不见. 提交于 2019-12-05 12:52:44

问题


I just created a node project and am trying to install jquery using bower.

bower install jquery

I get the following error:

bower jquery#*              not-cached git://github.com/jquery/jquery.git#*
bower jquery#*                 resolve git://github.com/jquery/jquery.git#*
bower jquery#*                   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._checkout (C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\lib\core\resolvers\GitHubResolver.js:54:21)
    at C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\lib\core\resolvers\GitResolver.js:69:21
    at _fulfilled (C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\node_modules\p-throttler\node_modules\q\q.js:798:54)
    at self.promiseDispatch.done (C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\node_modules\p-throttler\node_modules\q\q.js:827:30)
    at Promise.promise.promiseDispatch (C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\node_modules\p-throttler\node_modules\q\q.js:760:13)
    at C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\node_modules\p-throttler\node_modules\q\q.js:574:44
    at flush (C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\node_modules\p-throttler\node_modules\q\q.js:108:17)

Console trace:
Trace
    at StandardRenderer.error (C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\lib\renderers\StandardRenderer.js:72:17)
    at Logger.<anonymous> (C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\bin\bower:111:22)
    at Logger.emit (events.js:95:17)
    at Logger.emit (C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\node_modules\bower-logger\lib\Logger.js:29:39)
    at C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\lib\commands\index.js:40:20
    at _rejected (C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:797:24)
    at C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:823:30
    at Promise.when (C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:1035:31)
    at Promise.promise.promiseDispatch (C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:741:41)
    at C:\Users\Adam\AppData\Roaming\npm\node_modules\bower\node_modules\q\q.js:557:44

System info:
Bower version: 1.3.7
Node version: 0.10.29
OS: Windows_NT 6.2.9200 x64

I've tried installing other packages and they fail with the same error. I've got a pretty vanilla setup as far as I know. Running Windows 8.1 x64. Can't seem to find relevant info about why I'm getting this error.


回答1:


Fix: Clear cache and update to Bower 1.3.8.

This is what's going on:

The tmp package updated it's API to return a cleanup callback in addition to just the directory name. Q then squashes the two arguments to the callback into an array, while bower expected just a string for the directory name.

This causes "TypeError: Arguments to path.join must be strings" errors to appear, seemingly non-deterministic, because various spots attempt to use the _tempDir value (now an array) to join into a path.

semver ftw!




回答2:


For other people who are still running into this, this did the trick for me:

bower cache clean



回答3:


For me npm install -update bower was not sufficient.

I needed to install the version by specifing it explicit:

sudo npm install -q bower@1.3.8

and yes, I had to run this with sudo.



来源:https://stackoverflow.com/questions/24706416/bower-error-when-installing-package-arguments-to-path-join-must-be-strings

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!