question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

TypeError: func is not a function - npm

See original GitHub issue

I was using graphql-code-generator successfully, but now when I run npm run codegen, I’m getting func is not a function error. As suggested in #3256, I removed node_modules, package-lock.json and npm install from scratch, but it didn’t help.

I added a sandbox with same dependencies here: https://codesandbox.io/s/silly-haibt-3u7sq

Unfortunately, I cannot reproduce error there. Please advise.

✖ types/types.ts
    TypeError: func is not a function
        at .../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:259:19

Error message points to convertNameParts function:

function convertNameParts(str, func, removeUnderscore = false) {
    if (removeUnderscore) {
        return func(str);
    }
    return str
        .split('_')
        .map(s => func(s))
        .join('_');
}
Please click to see full error message
TypeError: func is not a function
        at .../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:259:19
        at Array.map (<anonymous>)
        at convertNameParts (.../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:259:10)
        at opts (.../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:425:24)
        at Object.convert (.../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:462:43)
        at TsVisitor.convertName (.../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:488:78)
        at TsVisitor._getTypeForNode (.../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:889:21)
        at TsVisitor.NamedType (.../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:892:21)
        at TsVisitor.NamedType (.../node_modules/@graphql-codegen/typescript/index.cjs.js:101:31)
        at Object.visit (.../node_modules/graphql/language/visitor.js:242:26)
        at Object.plugin (.../node_modules/@graphql-codegen/typescript/index.cjs.js:195:35)
        at executePlugin (.../node_modules/@graphql-codegen/core/index.cjs.js:50:41)
        at .../node_modules/@graphql-codegen/core/index.cjs.js:106:30
        at Array.map (<anonymous>)
        at Object.codegen (.../node_modules/@graphql-codegen/core/index.cjs.js:96:54)
        at process (.../node_modules/@graphql-codegen/cli/bin.js:783:67)
    TypeError: func is not a function
        at .../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:259:19
        at Array.map (<anonymous>)
        at convertNameParts (.../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:259:10)
        at opts (.../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:425:24)
        at Object.convert (.../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:462:43)
        at TsVisitor.convertName (.../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:488:78)
        at TsVisitor._getTypeForNode (.../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:889:21)
        at TsVisitor.NamedType (.../node_modules/@graphql-codegen/visitor-plugin-common/index.cjs.js:892:21)
        at TsVisitor.NamedType (.../node_modules/@graphql-codegen/typescript/index.cjs.js:101:31)
        at Object.visit (.../node_modules/graphql/language/visitor.js:242:26)
        at Object.plugin (.../node_modules/@graphql-codegen/typescript/index.cjs.js:195:35)
        at executePlugin (.../node_modules/@graphql-codegen/core/index.cjs.js:50:41)
        at .../node_modules/@graphql-codegen/core/index.cjs.js:106:30
        at Array.map (<anonymous>)
        at Object.codegen (.../node_modules/@graphql-codegen/core/index.cjs.js:96:54)
        at process (.../node_modules/@graphql-codegen/cli/bin.js:783:67)

Thanks,

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
ozumcommented, Jan 28, 2020

@ardatan, I updated the sandbox and problem seems to be solved. Case may be closed. Thanks.

1reaction
ozumcommented, Jan 26, 2020

Using below I’m getting same error with “npm install” from scratch. (yarn is still OK)

{
  "@graphql-codegen/cli": "1.11.3-alpha-21386b4a.87",
  "@graphql-codegen/typescript": "1.11.3-alpha-21386b4a.87",
  "@graphql-codegen/typescript-graphql-files-modules": "1.11.3-alpha-21386b4a.87",
  "@graphql-codegen/typescript-operations": "1.11.3-alpha-21386b4a.87"
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

node.js - firebase functions: TypeError: func is not a function
1. MDN docs states that this error arises when there is an attempt to call a value from a function, but the value...
Read more >
TypeError: "x" is not a function - JavaScript - MDN Web Docs
The JavaScript exception "is not a function" occurs when there was an attempt to call a value from a function, but the value...
Read more >
How to solve the "is not a function" error in JavaScript
js we use require() to load external modules and files. This can cause, in some cases, an error like this: TypeError: require(...) is...
Read more >
How to Handle JavaScript Uncaught TypeError: “x” is Not a ...
The Javascript TypeError: "x" is not a function occurs when calling a function on a value or object, which is not actually a...
Read more >
JavaScript: Uncaught TypeError: n is not a function
Uncaught TypeError: 'n' is not a function: This is a standard JavaScript error when trying to call a function before it is defined....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found