Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

486
Views
React/node build error. Could not find a declaration file for module 'history'. 'node_modules/history/index.js' implicitly has an 'any' type

My project is suddenly having a build error. My current repo still has no problem, it only happens when I clone the repo to a new folder and install the package again then do npm run build. So I am so scared to update the package right now...

I checked the merge history, I don't think any code merge should cause this issue..

Here is the error message I got:

$ npm run build

> container-client@2.32.0 build I:\ds\projects\new\container-service\client
> craco build

Creating an optimized production build...
Failed to compile.

I:/ds/projects/new/container-service/client/src/views/add-application/AddApplicationPage.tsx
TypeScript error in I:/ds/projects/new/container-service/client/src/views/add-application/AddApplicationPage.tsx(4,25):
Could not find a declaration file for module 'history'. 'I:/ds/projects/new/container-service/client/node_modules/history/index.js' implicitly has an 'any' type.
  If the 'history' package actually exposes this module, consider sending a pull request to amend 'https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/history`  TS7016

    2 | import './_index.scss';
    3 | import store from '../../store';
  > 4 | import { History } from 'history';
      |                         ^
      

This is the package.json:

  {
  "private": false,
  "dependencies": {
    "axios": "^0.19.2",
    "bootstrap": "^4.6.0",
    "history": "^4.10.1",
    "identity-obj-proxy": "^3.0.0",
    "react": "~17.0.1",
    "react-app-polyfill": "~2.0.0",
    "react-dom": "~17.0.1",
    "react-router-dom": "~5.2.0"
  },

Looks like the library "history" is causing the problem. 

I tried:

  1. delete the node_module --> npm install --> npm run build --> same error
  2. clone the project again --> npm install --> npm run build --> same error
  3. clone the older version of the project --> npm install --> npm run build --> same error

Nothing seems to work.

over 4 years ago · Santiago Trujillo
2 answers
Answer question

0

the problem seems to be from the history package that you are using

Could not find a declaration file for module 'history'.

try installing types for the package

npm i @types/history

if that didn't work, then change the import to require

const history = require("history")

update

the @types/history is deprecated and since version 5 of history, the type declarations are provided inside the package itself. updating the package should fix the issue:

npm install history@latest
over 4 years ago · Santiago Trujillo Report

0

Looks like the new history needs a dependency library @types/history. I did a npm i @types/history@4.7.9 and then did a npm i again. This fixed my problem.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!