TypeError: func is not a function - npm
See original GitHub issueI 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:
- Created 4 years ago
- Comments:14 (2 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@ardatan, I updated the sandbox and problem seems to be solved. Case may be closed. Thanks.
Using below I’m getting same error with “npm install” from scratch. (yarn is still OK)