1
2

More than 5 years have passed since last update.

clasp login で TypeError が出る

Posted at

Google Apps Script(GAS)をローカルで開発をしたくて、
google/claspをインストールしました。

最初のステップとして、ログイン(clasp login)をするのですが、
コマンドを実行すると[Error retrieving access token: TypeError: URL is not a constructor]が出て開発環境すら作れない。

% clasp login
Logging in globally...
🔑 Authorize clasp by visiting this url:
https://accounts.google.com/o/oauth2/v2/auth?access_type=offline&・・・・


Error retrieving access token: TypeError: URL is not a constructor

当然、~/.clasprc.json は作成されません。

原因は node のバージョンが古かったからです。
因みに私のバージョンは v6.4.0 でした。

% node -v
v6.4.0

node のバージョンを上げました。

上げる方法は色々とあると思うのですが、私は nodebrew を使っています。
いや、使っているのを忘れていて

brew install node

なんのでやっても、 node のバージョンが上がらなくてハマりました。
更に nodebrew が壊れていて無限にインストールできなくてまたハマりました。

以下を参考にして nodebrew を入れ直しました。
nodebrewでinstallが失敗するようになった

今回は最新の安定バージョンの node を入れたかったので
以下の nodebrew コマンドでインストールしました。

nodebrew install-binary stable

その後に

nodebrew use stable
use v12.1.0

2019年05月06日現在です。

clasp login
Logging in globally...
(node:952) [DEP0066] DeprecationWarning: OutgoingMessage.prototype._headers is deprecated
🔑 Authorize clasp by visiting this url:
https://accounts.google.com/o/oauth2/v2/auth?access_type=offline・・・・

Authorization successful.

Default credentials saved to: ~/.clasprc.json 

[Error retrieving access token: TypeError: URL is not a constructor]が
でなくなりました。
ここ何年もnodeのバージョンを上げてなかったので、こんなに上がっているのって
びっくりしました。

1
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
2