formik: Typescript 2.9 generated declaration types have wrong import path

With formik beta-3, got an error like this one :

/frontend/node_modules/formik/dist/connect.d.ts
(3,59): Cannot find module '../node_modules/create-react-context/lib/index'.

/frontend/node_modules/formik/dist/connect.d.ts
(3,189): Cannot find module '../node_modules/create-react-context/lib/index'.
  • Formik Version:1.0.0-beta.3
  • React Version:16.4.1
  • TypeScript Version:2.9.2
  • OS: windows
  • Node Version:10.5.0

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 2
  • Comments: 25 (13 by maintainers)

Commits related to this issue

Most upvoted comments

Also getting this issue currently.

Node 10.1.0 React 16.7.0 Typescript 3.2.2 Formik 1.4.2

If I add create-react-context to my deps then its fine.

Error is:

ERROR in ./node_modules/formik/dist/formik.esm.js
Module not found: Error: Can't resolve 'create-react-context' in 'repo/node_modules/formik/dist'
「wdm」: Failed to compile.

Is there some reason this issue is closed? Seems like people are still running into the problem.

@vladshcherbin I had the same issue. Formik is compiled to ES5 (target ES5) which means that you have to set "moduleResolution": "Node", it helped for me. For more information read https://www.typescriptlang.org/docs/handbook/compiler-options.html.

@gunn4r This fixed it for me as well. I’m baffled as to why.

EDIT: node 8.9.4 typescript 3.3.1 react 16.2.0 formik 1.1.1

Fixed for me.

Try 1.0.0-beta.8. This should be fixed now.

/projects/demo/node_modules/formik/dist/connect.d.ts
(3,59): Cannot find module '../node_modules/create-react-context/lib/index'.

Same issue here with beta 4. Deleted the node_modules as suggested and did a reinstall.

Switching back to 0.11.11 solved it.