Create-react-app: running 'npm start' command results with a TypeError: argument fn must be a function exception coming from depd

Created on 3 Jul 2019  路  13Comments  路  Source: facebook/create-react-app

Desribe the bug

After running 'npm start' command, it throws an error and it doesn't start

node_modules\depd\index.js:399
throw new TypeError('argument fn must be a function')
^

TypeError: argument fn must be a function
at Function.wrapfunction [as function] (...ClientAppnode_modules\depd\index.js:399:11)
at populateConstructorExports (...ClientAppnode_modules\http-errors\index.js:264:45)
at Object. (...ClientAppnode_modules\http-errors\index.js:30:1)

Did you try recovering your dependencies?

Yes, it didn't work.

Which terms did you search for in User Guide?

I searched depd TypeError terms in internet but couldn't find any relevant information.

Environment

System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Binaries:
Node: 12.5.0 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 42.17134.1.0
Internet Explorer: 11.0.17134.1
npmPackages:
react: ^16.0.0 => 16.8.6
react-dom: ^16.0.0 => 16.8.6
react-scripts: 3.0.1 => 3.0.1
npmGlobalPackages:
create-react-app: Not Found

Steps to reproduce

  1. run command npx create-react-app my-app
  2. open project directory by using comment cd my-app
  3. run the app via comment npm start

Expected behavior

It should run the application without any errors.

Actual behavior

It throws an error
node_modules\depd\index.js:399
throw new TypeError('argument fn must be a function')
^

TypeError: argument fn must be a function
at Function.wrapfunction [as function] (...ClientAppnode_modules\depd\index.js:399:11)
at populateConstructorExports (...ClientAppnode_modules\http-errors\index.js:264:45)
at Object. (...ClientAppnode_modules\http-errors\index.js:30:1)

If I remove Node 12.5.0 and install 10.16.0 and follow the reproduction steps mentioned above, it runs the application successfully.

bug

Most helpful comment

You're right. It's not a bug in CRA.
You gave me a really great hint.
The primary language of the Windows was Turkish. After installing English and changing default application language to English, the problem has gone.
By the way, In Turkish I is not capital i. I think the problem related with that.
Thank you for your support.

All 13 comments

Interesting. The line that throws is:

exports["I'mateapot"] = deprecate.function(exports.ImATeapot,
    '"I\'mateapot"; use "ImATeapot" instead')

Which implies that exports.ImATeapot is not defined as a function. So either it's not being picked up by the iteration above, or toidentifier("I'm a teapot") !== ImATeapot.

In any case, I'm not able to repro using 12.5.0. Could you go into node_modules/http-errors/index.js and add console.log(exports) right before that line?

this is the output of console.log(exports) :

[Function: createError] {
  '400': [Function: BadRequestError],
  '401': [Function: UnauthorizedError],
  '402': [Function: PaymentRequiredError],
  '403': [Function: ForbiddenError],
  '404': [Function: NotFoundError],
  '405': [Function: MethodNotAllowedError],
  '406': [Function: NotAcceptableError],
  '407': [Function: ProxyAuthenticationRequiredError],
  '408': [Function: RequestTimeoutError],
  '409': [Function: ConflictError],
  '410': [Function: GoneError],
  '411': [Function: LengthRequiredError],
  '412': [Function: PreconditionFailedError],
  '413': [Function: PayloadTooLargeError],
  '414': [Function: URTooLongError],
  '415': [Function: UnsupportedMediaTypeError],
  '416': [Function: RangeNotSatisfiableError],
  '417': [Function: ExpectationFailedError],
  '418': [Function: mATeapotError],
  '421': [Function: MisdirectedRequestError],
  '422': [Function: UnprocessableEntityError],
  '423': [Function: LockedError],
  '424': [Function: FailedDependencyError],
  '425': [Function: UnorderedCollectionError],
  '426': [Function: UpgradeRequiredError],
  '428': [Function: PreconditionRequiredError],
  '429': [Function: TooManyRequestsError],
  '431': [Function: RequestHeaderFieldsTooLargeError],
  '451': [Function: UnavailableForLegalReasonsError],
  '500': [Function: nternalServerError],
  '501': [Function: NotmplementedError],
  '502': [Function: BadGatewayError],
  '503': [Function: ServiceUnavailableError],
  '504': [Function: GatewayTimeoutError],
  '505': [Function: HTTPVersionNotSupportedError],
  '506': [Function: VariantAlsoNegotiatesError],
  '507': [Function: nsufficientStorageError],
  '508': [Function: LoopDetectedError],
  '509': [Function: BandwidthLimitExceededError],
  '510': [Function: NotExtendedError],
  '511': [Function: NetworkAuthenticationRequiredError],
  HttpError: [Function: HttpError],
  BadRequest: [Function: BadRequestError],
  Unauthorized: [Function: UnauthorizedError],
  PaymentRequired: [Function: PaymentRequiredError],
  Forbidden: [Function: ForbiddenError],
  NotFound: [Function: NotFoundError],
  MethodNotAllowed: [Function: MethodNotAllowedError],
  NotAcceptable: [Function: NotAcceptableError],
  ProxyAuthenticationRequired: [Function: ProxyAuthenticationRequiredError],
  RequestTimeout: [Function: RequestTimeoutError],
  Conflict: [Function: ConflictError],
  Gone: [Function: GoneError],
  LengthRequired: [Function: LengthRequiredError],
  PreconditionFailed: [Function: PreconditionFailedError],
  PayloadTooLarge: [Function: PayloadTooLargeError],
  URTooLong: [Function: URTooLongError],
  UnsupportedMediaType: [Function: UnsupportedMediaTypeError],
  RangeNotSatisfiable: [Function: RangeNotSatisfiableError],
  ExpectationFailed: [Function: ExpectationFailedError],
  mATeapot: [Function: mATeapotError],
  MisdirectedRequest: [Function: MisdirectedRequestError],
  UnprocessableEntity: [Function: UnprocessableEntityError],
  Locked: [Function: LockedError],
  FailedDependency: [Function: FailedDependencyError],
  UnorderedCollection: [Function: UnorderedCollectionError],
  UpgradeRequired: [Function: UpgradeRequiredError],
  PreconditionRequired: [Function: PreconditionRequiredError],
  TooManyRequests: [Function: TooManyRequestsError],
  RequestHeaderFieldsTooLarge: [Function: RequestHeaderFieldsTooLargeError],
  UnavailableForLegalReasons: [Function: UnavailableForLegalReasonsError],
  nternalServerError: [Function: nternalServerError],
  Notmplemented: [Function: NotmplementedError],
  BadGateway: [Function: BadGatewayError],
  ServiceUnavailable: [Function: ServiceUnavailableError],
  GatewayTimeout: [Function: GatewayTimeoutError],
  HTTPVersionNotSupported: [Function: HTTPVersionNotSupportedError],
  VariantAlsoNegotiates: [Function: VariantAlsoNegotiatesError],
  nsufficientStorage: [Function: nsufficientStorageError],
  LoopDetected: [Function: LoopDetectedError],
  BandwidthLimitExceeded: [Function: BandwidthLimitExceededError],
  NotExtended: [Function: NotExtendedError],
  NetworkAuthenticationRequired: [Function: NetworkAuthenticationRequiredError]
}

Just fyi, it's nicer to format stack traces with fenced blocks since we don't have to worry as much about markdown misinterpreting things.

The source of the error is pretty obvious; somehow the capital Is in every status code have been removed. You should console.log(codes) and also console.log(toIdentifier("I'm A Teapot") in the same place to see whether the its toIdentifier trimming them or if they're just that way in node_modules/statuses/codes.json. Seems very strange to me, but definitely not a bug in CRA. I'm very surprised that recovering your deps didn't work to fix it, but that makes me pretty sure it's literally something wrong with your computer.

You're right. It's not a bug in CRA.
You gave me a really great hint.
The primary language of the Windows was Turkish. After installing English and changing default application language to English, the problem has gone.
By the way, In Turkish I is not capital i. I think the problem related with that.
Thank you for your support.

Ah, very interesting! I鈥檝e never seen an issue like this before, so I learned something new today. Glad you got it worked out.

Desribe the bug

After running 'npm start' command, it throws an error and it doesn't start

node_modules\depd\index.js:399
throw new TypeError('argument fn must be a function')
^

TypeError: argument fn must be a function
at Function.wrapfunction [as function] (...ClientAppnode_modules\depd\index.js:399:11)
at populateConstructorExports (...ClientAppnode_modules\http-errors\index.js:264:45)
at Object. (...ClientAppnode_modules\http-errors\index.js:30:1)

Did you try recovering your dependencies?

Yes, it didn't work.

Which terms did you search for in User Guide?

I searched depd TypeError terms in internet but couldn't find any relevant information.

Environment

System:
OS: Windows 10
CPU: (8) x64 Intel(R) Core(TM) i7-7820HQ CPU @ 2.90GHz
Binaries:
Node: 12.5.0 - C:\Program Files\nodejs\node.EXE
Yarn: Not Found
npm: 6.9.0 - C:\Program Files\nodejs\npm.CMD
Browsers:
Edge: 42.17134.1.0
Internet Explorer: 11.0.17134.1
npmPackages:
react: ^16.0.0 => 16.8.6
react-dom: ^16.0.0 => 16.8.6
react-scripts: 3.0.1 => 3.0.1
npmGlobalPackages:
create-react-app: Not Found

Steps to reproduce

  1. run command npx create-react-app my-app
  2. open project directory by using comment cd my-app
  3. run the app via comment npm start

Expected behavior

It should run the application without any errors.

Actual behavior

It throws an error
node_modules\depd\index.js:399
throw new TypeError('argument fn must be a function')
^

TypeError: argument fn must be a function
at Function.wrapfunction [as function] (...ClientAppnode_modules\depd\index.js:399:11)
at populateConstructorExports (...ClientAppnode_modules\http-errors\index.js:264:45)
at Object. (...ClientAppnode_modules\http-errors\index.js:30:1)

If I remove Node 12.5.0 and install 10.16.0 and follow the reproduction steps mentioned above, it runs the application successfully.

@tzairos
I am Turkish too and I have the same problem with you. I changed the default application language as English then try npm install but the problem is go on. Can you help me?

I got the same mistake.
It improved when I changed the node version.

version I use:12.6.0
version I changed:11.4.0

Node.JS to install a new version.
NVM install and
nvm install **nodeVersion**
after
nvm use **nodeVersion**

interesting but I solved the same problem by changing the language of windows to English.

Open the file node_modules\depd\index.js and change the function below.

function wrapfunction (fn, message) {
if (fn == undefined) return; // Add this line to solve the problem
if (typeof fn !== 'function') {
throw new TypeError('argument fn must be a function ' + fn)
}

@heyimalex I am having the same problem with @tzairos but I am using Windows 10 Home Single Languge so no option to change the computer language.

@isiuiki You should re-install Windows 10. Default language must be English. If you don't want to deal with it, you can downgrade the version of node.js. This is how I solved the problem. Downgrade the version from 12.6.0 to 10.16.0

When I use "i", an alphanumeric error occurs. improved after changing default language

Error Example
"firstapp" is not a valid name for a project. Please use a valid identifier name (alphanumeric).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

fson picture fson  路  3Comments

Aranir picture Aranir  路  3Comments

alleroux picture alleroux  路  3Comments

dualcnhq picture dualcnhq  路  3Comments

xgqfrms-GitHub picture xgqfrms-GitHub  路  3Comments