Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught TypeError: exec is not a function #107

Open
grzeczko opened this issue Mar 31, 2020 · 2 comments
Open

Uncaught TypeError: exec is not a function #107

grzeczko opened this issue Mar 31, 2020 · 2 comments

Comments

@grzeczko
Copy link

I'm getting the following error when attempting to require google-translate-api:

Uncaught TypeError: exec is not a function

I'm including it with the following code:

const translate = require('google-translate-api');

When I look at my console, here is the code snippet it's complaining about:

`var isWindows = process.platform === 'win32'
var path = require('path')
var exec = require('child_process').exec
var osTmpdir = require('os-tmpdir')
var osHomedir = require('os-homedir')

// looking up envs is a bit costly.
// Also, sometimes we want to have a fallback
// Pass in a callback to wait for the fallback on failures
// After the first lookup, always returns the same thing.
function memo (key, lookup, fallback) {
var fell = false
var falling = false
exports[key] = function (cb) {
var val = lookup()
if (!val && !fell && !falling && fallback) {
fell = true
falling = true
exec(fallback, function (er, output, stderr) {
falling = false
if (er) return // oh well, we tried
val = output.trim()
})
}
exports[key] = function (cb) {
if (cb) process.nextTick(cb.bind(null, null, val))
return val
}
if (cb && !falling) process.nextTick(cb.bind(null, null, val))
return val
}
}`

Anyone know what the issue may be?

Thank you.

@BriungRi
Copy link

I was trying to build a web application that used this package, and I ran into the same issue as you. I think it's because this package is meant to be used in a backend node.js service rather than from a browser. I found the snippet that was err'ing out from the osenv package, and I noticed that some other javascript users ran into similar issues

ref: ActiveCampaign/postmark.js#1

@braco
Copy link

braco commented Jan 18, 2021

@BriungRi good call, it seems to be from the configstore package:

% npm ls osenv
/project
└─┬ google-translate-api@2.3.0
  └─┬ configstore@2.1.0
    └── osenv@0.1.5 

Doesn't seem like @matheuss is still maintaining this repo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants