Skip to content

TypeError: Cannot call method 'clone' of undefined #91

@attilagyorffy

Description

@attilagyorffy

Been following the examples from the readme and seems like there's something wrong:

Here's my example code:

var git = require('nodegit');

var path = '/tmp/';

git.Repo.clone("https://github.com/nodegit/nodegit.git", path, null, function(error, repo) {
  if (error) throw error;

  repo.getCommit('59b20b8d5c6ff8d09518454d4dd8b7b30f095ab5', function(error, commit) {
    if (error) throw error;

    commit.getEntry('README.md', function(error, entry) {
      if (error) throw error;

      entry.getBlob(function(error, blob) {
        if (error) throw error;

        console.log(entry.name(), entry.sha(), blob.size() + 'b');
        console.log('========================================================\n\n');
        var firstTenLines = blob.toString().split('\n').slice(0, 10).join('\n');
        console.log(firstTenLines);
        console.log('...');
      });
    });
  });
});
git.Repo.clone("https://github.com/nodegit/nodegit.git", path, null, function(
         ^
TypeError: Cannot call method 'clone' of undefined
    at Object.<anonymous> (/Users/attila/Projects/node-testing/git-example.js:5:10)
    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)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

It is also not entirely clear how to try cloning a repository based on the docs. Could you add an example please that shows how to require the module properly and then how to clone a repo? Thank you.

Using the latest node as of today: v0.10.18

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions