git-repository
git-repository copied to clipboard
ReferenceError: regeneratorRuntime is not defined
Seems to be an error when trying to run the open() method.
at Function.open (....../node_modules/git-repository/lib/Repository.js:198:14)
This is line 198 in lib/Repository.js:
return regeneratorRuntime.async(function open$(context$2$0) {
Node: 6.9.1
Other: Using like: node -r ts-node/register some-module-that-uses-git-repository
I actually can't find regeneratorRuntime defined anywhere in the compiled/generated files.
I resolved this by finding that babel-polyfill is actually required to be pre-required first.
See: https://stackoverflow.com/questions/33527653/babel-6-regeneratorruntime-is-not-defined-with-async-await#33527883
Workaround:
node -r ts-node/require -r babel-polyfill some-module-that-uses-git-repository
This should be capable of being run right in Node without needing anything else.
How you might fix this is depending on regenerator-runtime.
npm install regenerator-runtime -S
Then in src/Repository.js
/**
* Copyright © 2015 Konstantin Tarkus. All rights reserved.
*
* This source code is licensed under the MIT license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
import { join, resolve } from 'path';
// Expose regeneratorRuntime() as global function so that the
// async functions (after being compiled) can run in plain Node
import 'regenerator-runtime/runtime'
import cp from './utils/cp';
import fs from './utils/fs';
class Repository {