0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

claspがTypeError: dotf is not a functionで詰まった話

Last updated at Posted at 2019-05-24

はじめに

claspの環境構築については今回は省略させていただきます

  • 使用PC:mac
  • claspのバージョン(2019年5月23日現在)
$ clasp -v
2.1.0

詰まった部分

claspのGitHubに書かれている通りにnpm installした

$ npm i @google/clasp -g

その後 clasp を実行すると

$ clasp
/usr/local/lib/node_modules/@google/clasp/src/dotfile.js:89
    RC: dotf(exports.DOT.RC.DIR, exports.DOT.RC.NAME),
        ^

TypeError: dotf is not a function
    at Object.<anonymous> (/usr/local/lib/node_modules/@google/clasp/src/dotfile.js:89:9)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)
    at Module.load (internal/modules/cjs/loader.js:628:32)
    at Function.Module._load (internal/modules/cjs/loader.js:555:12)
    at Module.require (internal/modules/cjs/loader.js:666:19)
    at require (internal/modules/cjs/helpers.js:16:16)
    at Object.<anonymous> (/usr/local/lib/node_modules/@google/clasp/src/auth.js:57:17)
    at Module._compile (internal/modules/cjs/loader.js:759:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:770:10)

どうやらdotfに問題があるらしい

解決策

エラーメッセージにもあるように
/usr/local/lib/node_modules/@google/clasp/src/dotfile.jsを編集する
最終的にdotfを以下のように編集することで解決した

dotf()
  ↓
dotf.default()

編集後のソースコード(79行目から)

    /**
     * Gets the closest DOT.PROJECT.NAME in the parent directory of the directory
     * that the command was run in.
     * @return {dotf} A dotf with that dotfile. Null if there is no file
     */
    PROJECT: function () {
        var projectDirectory = findParentDir.sync(process.cwd(), exports.DOT.PROJECT.PATH) || exports.DOT.PROJECT.DIR;
        return dotf.default(projectDirectory, exports.DOT.PROJECT.NAME);
    },
    // Stores {ClaspCredentials}
    RC: dotf.default(exports.DOT.RC.DIR, exports.DOT.RC.NAME),
    // Stores {ClaspCredentials}
    RC_LOCAL: function () {
        var localDirectory = findParentDir.sync(process.cwd(), exports.DOT.PROJECT.PATH) || exports.DOT.RC.LOCAL_DIR;
        return dotf.default(localDirectory, exports.DOT.RC.NAME);
    },
};

終わりに

自分のclaspの環境構築のやり方が悪かった可能性の方が高いと思ってるので原因わかる人教えてください

0
0
2

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
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?