The error message "Declaration file for module 'mime' not found" was issued when trying to pnpm firebase app

Currently, I am in the process of transitioning from yarn to pnpm within my turborepo monorepo setup. However, I have run into an issue while executing lint or build commands:

../../node_modules/.pnpm/@<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="04707d7461772f776176726129777065706d6744352a35331c332f">[email protected]</a>/node_modules/@types/serve-static/index.d.ts:4:20 
- error TS7016: Could not find a declaration file for module 'mime'. 
'/path-to-project/node_modules/.pnpm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0a6763676f4a39243a243a">[email protected]</a>/node_modules/mime/index.js' implicitly has an 'any' type.

Upon further investigation, it appears that deep within my dependency graph, @types/mime is installed but labeled as deprecated and redundant according to npm documentation: This is a stub types definition. mime provides its own type definitions, so you do not need this installed

  • The problem does not arise when using yarn.
  • When starting a new node/express project with pnpm, the same dependencies exist in .pnpm without encountering the issue.

After delving into root/node_modules/.pnpm and root/pnpm-lock.yaml, the troublesome dependency path seems to be:

<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1f79766d7a7d7e6c7a32796a717c6b7670716c5f2b3127313d">[email protected]</a> --> @types/<a</questionbody>
<exquestionbody>
<div class="question">
                
<p>I'm looking to switch from yarn to pnpm within my turborepo monorepo structure.
Encountering the following error while running lint or build:</p>
<pre><code>../../node_modules/.pnpm/@<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="04707d7461772f776176726129777065706d6744352a35312a31">[email protected]</a>/node_modules/@types/serve-static/index.d.ts:4:20 
- error TS7016: Could not find a declaration file for module 'mime'. 
'/path-to-project/node_modules/.pnpm/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="0a6763676f4a39243a243a">[email protected]</a>/node_modules/mime/index.js' implicitly has an 'any' type.

It seems like somewhere down the line in my dependencies tree, @types/mime is present even though it's marked as both deprecated and redundant, per npm guidelines: This is a stub types definition. mime provides its own type definitions, so you do not need this installed

  • No such issue arises when using yarn.
  • Observing the dependencies in .pnpm when initiating another node/express project with pnpm, the issue doesn't manifest.

Upon inspecting root/node_modules/.pnpm and root/pnpm-lock.yaml, it appears that the problematic dependency chain is:

<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="1f79766d7a7d7e6c7a32796a717c6b7670716c5f2b3127312d">[email protected]</a> --> @types/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="d6b3aea6a4b3a5a596e2f8e7e1f8e5">[email protected]</a> --> @types/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="2b584e595d4e06585f4a5f42486b1a051a1e051e">[email protected]</a> --> @types/<a href="/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="84e9ede9e1c4b0aab4aab4">[email protected]</a>

Attempts made so far include:

  • pnpm store prune
  • reinstalling pnpm
  • package reinstallation in root/apps/project
  • Multiple clean-ups of the entire project for cache folders, node_modules, and .lock files, followed by a complete reinstallation of all dependencies.

Any insights on why this issue persists?

pnpm v8.15.5

root/apps/project/tsconfig.json

{
  "compilerOptions": {
    "module": "commonjs",
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "outDir": "lib",
    "sourceMap": true,
    "strict": true,
    "target": "es2017"
  },
  "compil

eOnSave": true, "include": [ "src" ] }

root/apps/project/package.json

  "dependencies": {
    "firebase-admin": "^12.0.0",
    "firebase-functions": "^4.8.2"
  },
  "devDependencies": {
    "event-dee-types": "workspace:*",
    "firebase-functions-test": "^3.1.1",
    "typescript": "^4.9.0"
  },

root/package.json

 "dependencies": {
    "daisyui": "4.6.0",
    "dotenv-cli": "^7.2.1",
    "next": "latest",
    "react": "^18.2.0",
    "react-dom": "^18.2.0"
  },
  "devDependencies": {
    "@types/node": "^20.10.4",
    "@types/react": "^18.0.22",
    "@types/react-dom": "^18.0.7",
    "autoprefixer": "^10.4.14",
    "eslint": "^7.32.0",
    "eslint-config-custom": "workspace:*",
    "postcss": "^8.4.21",
    "sass": "^1.62.0",
    "tailwindcss": "^3.3.1",
    "turbo": "latest",
    "typescript": "^5.0.4"
  }

Answer №1

To uninstall, enter this command in your terminal:

pnpm remove @types/mime

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Redux Saga effect does not have a matching overload for this call

Encountering an error in my Redux Saga file, specifically when using the takeLatest() Saga effect. TypeScript is throwing the following error: (alias) const getMovies: ActionCreatorWithoutPayload<string> import getMovies No overload matches this call ...

Acquiring numerous query string parameters in Express 4

const express = require('express'); const bodyParser = require('body-parser'); const app = express(); const url = require('url'); // middleware to parse application/x-www-form-urlencoded app.use(bodyParser.urlencoded({ extend ...

Node Express failing to run dynamically added middleware

I am currently setting up the rate-limit feature in my node express application. I have been facing difficulties in configuring the rate limit middleware as I fetch the configurations from an external API. Despite trying to update the middleware after rece ...

Employing res.sendStatus(200) in conjunction with JQuery AJAX

I've implemented a form that triggers an AJAX call to my backend, utilizing Node and Express. The onsubmit function is responsible for this interaction. Once the submission is successful, I use res.sendStatus(200) to inform the client. This results i ...

An error that was not foreseen has arisen from the deletion code in Node.js

Having trouble deleting a post in my node project. Even though the delete function is working, an error is being thrown and I can't figure out where it's coming from. I've tried debugging by printing steps to console. Any help in identifyin ...

Angular Universal causing issues with updating the DOM component

@Component({ selector: 'mh-feature-popup', template: ` <div class="full"> <div> <div class="container-fluid" [@featurepop]="state"> <div class="row"> <div class="col-xs-12 col-md-4 col-md-offse ...

The specified type does not meet the constraint as it lacks the required index signature

I'm currently working on refactoring a TypeScript project that utilizes React Hooks. While I have some knowledge of TypeScript, I am still more of a beginner than an expert. My main goal is to create reusable code for this project through the use of ...

Node.Js error: "The requested resource does not have the 'Access-Control-Allow-Origin' header present."

This particular query shares similarities with others, however there is a perplexing difference that is causing it to malfunction. Previously, my JavaScript was able to fetch 6 json files without any issues. In Node.JS, I have configured cors and headers ...

Encountering an issue with the property 'indexOf' in socketiojwt that is preventing proper reading

When attempting to integrate the socketio-jwt module into my app project for authentication purposes, I followed the basic code provided on their documentation. Despite running the app without any errors, I encountered a problem when trying to access the U ...

Expanding IntelliSense and helpful tooltips in VSCode for JavaScript and TypeScript by utilizing Node.js for a deeper understanding

As a beginner in programming, specifically in JS/TS, I've been experimenting with node.js and have encountered a puzzling issue with the IntelliSense or 'helptext' feature in VSCode. For instance, when attempting to use fs.open(), I receive ...

Adding a second interface to a Prop in Typescript React: a step-by-step guide

import { ReactNode, DetailedHTMLProps, FormHTMLAttributes } from "react"; import { FieldValues, SubmitHandler, useForm, UseFormReturn, } from "react-hook-form"; // I am looking to incorporate the DetailedHTMLProps<FormHTMLAt ...

Unable to successfully import { next } from the 'express' module using Typescript

Having some trouble with this line of code: import {response, request, next} from 'express' The typescript compiler in vscode is giving me the following error: Module '"express"' has no exported member 'next'. Up ...

The property 'x' cannot be found on the data type 'true | Point'

I am dealing with a variable named ctx which can be either of type boolean or Point. Here is how Point is defined: type Point = { x: number y: number } In my React component, I have the following setup: const App = () => { const [ctx, toggleC ...

Tips for effectively updating the API after making changes to the Swagger specification file in an express and Node.js environment

Looking to set up a nodejs-express boilerplate for my latest project, and this time I want to experiment with a doc-driven approach. Explored various packages like swagger-node, swaggerize-express ...and more, all offering excellent functionality. However ...

The parameter type '(req: Request, res: Response, next: NextFunction) => void' does not match the type of 'Application<Record<string, any>>'

I'm currently working on an Express project that utilizes TypeScript. I have set up controllers, routers, and implemented a method that encapsulates my controller logic within an error handler. While working in my router.ts file, I encountered an err ...

Advantages of Using Constructor Parameter Initialization Over the new Keyword in Angular 5

Sample CODE 1 : import { Component,OnInit } from '@angular/core'; import {exampleClass} from './exampleClass' @Component({ selector: 'app-root', templateUrl: './app.component.html', styleU ...

What are some reasons for express middleware not functioning properly when utilized in separate files?

I am trying to organize my routers by breaking them down into separate files rather than keeping all API routes in a single file. However, when I attempt to identify the user URL using middleware and call the appropriate API based on the URL, the middlewar ...

The outcome from using Array.reduce may not always match the expected result

After discovering an unexpected behavior in Typescript's type-inference, I suspect there may be a bug. Imagine having a list of the MyItem interface. interface MyItem { id?: string; value: string; } const myItemList: MyItem[] = []; It's ...

Error message: "Incompatible types in Typescript"

As I delve into learning TypeScript, I have encountered two errors that are causing me some trouble. We have a problem with the following lines of code: Type 'string | null | undefined' is not assignable to type 'string | RegExp | QuerySelec ...

Encountered a cyclic dependency in MongoDB when attempting to create an index

I have a dataset structured as shown in the image below: https://i.sstatic.net/eu2ZH.png I am attempting to write a query using $near. However, when trying to create an index for this query, I encounter an error stating "cyclic dependency detected". Below ...