NextJS: Build error - TypeScript package not detected

I'm facing an issue while setting up my NextJS application in TypeScript on my hosting server. On my local machine, everything works fine when I run next build. However, on the server, I'm encountering this error:

> next build

It seems that TypeScript is not installed on your system.

To resolve this, please install typescript by running:

npm install --save-dev typescript

If you're not using TypeScript, make sure to remove the tsconfig.json file from the package root (and any TypeScript files in the pages directory).

I've tried installing TypeScript with both:

npm install --save-dev typescript
and npm -g typescript, but the error persists.

Here's a snippet from my package.json:

...
"scripts": {
    // Your scripts here
},
"dependencies": {
    // Your dependencies here
  },
  "devDependencies": {
    // Your dev dependencies here
  }
...

Both my local computer and the server are running Node 16.15.1. The server uses pm2 to execute the script (I even tried running it manually through SSH, but the error remains).

I can't figure out why this error is occurring despite having TypeScript installed. Any help would be appreciated!

Answer №1

An important problem arises when TypeScript is included as a development dependency, as it should not be installed in a production setting.

To address this issue, simply relocate the line

"typescript": "4.6.4",
from the devDependencies section to dependencies within your package.json file.

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

How come the hover effect is not functioning properly following the addition of padding to

I have set a padding top of 120px, but for some reason the hover effect is not working properly. Can anyone help me troubleshoot this issue? Here is the code snippet: 'use client'; // eslint-disable-next-line no-unused-vars import React, { useSta ...

When making an Axios API request in Next.js, an error is encountered stating that the property 'map' cannot be read as it is undefined

Hey there! I've been trying to fetch data from the API endpoint in my NextJs application using axios. However, whenever I try to map over the retrieved data, NextJs keeps throwing the error message "TypeError: Cannot read property 'map' of ...

Why is the source alignment different when using Next.js compared to WordPress?

As a newcomer to NextJS, I am eager to learn more about it in order to develop websites that are easily discoverable by Google's search engine algorithms and have strong SEO performance. Wordpress is renowned for its SEO capabilities as it neatly outp ...

Troubles encountered while attempting to properly mock a module in Jest

I've been experimenting with mocking a module, specifically S3 from aws-sdk. The approach that seemed to work for me was as follows: jest.mock('aws-sdk', () => { return { S3: () => ({ putObject: jest.fn() }) }; }); ...

Combining attributes of objects in an array

Is the title accurate for my task? I have an array structured like this: { "someValue": 1, "moreValue": 1, "parentArray": [ { "id": "2222", "array": [ { "type": "test", "id": "ID-100" }, { ...

Tips for passing TouchableOpacity props to parent component in React Native

I created a child component with a TouchableOpacity element, and I am trying to pass props like disabled to the parent component. Child component code: import React from 'react'; import {TouchableOpacity, TouchableOpacityProps} from 'react- ...

The issue occurs when using NextJS in conjunction with React-Query, where the query disappears from the React-Query DevTools after clicking on the link for a

Using the react-query hook export const useSearchClient: UseSearchClient = (filters) => { return useQuery({ queryKey: ['clients'], queryFn: queryFn(filters), enabled: false, }) } Implementing the client component const { data, ...

Methods for bypassing a constructor in programming

I am working on a code where I need to define a class called programmer that inherits from the employee class. The employee class constructor should have 4 parameters, and the programmer class constructor needs to have 5 parameters - 4 from the employee c ...

What are the steps to set up tsline in settings.json file?

Currently utilizing visual studio code Upon searching for the settings.json file, the contents appear as follows: { "liveServer.settings.donotVerifyTags": true, "liveServer.settings.donotShowInfoMsg": true, "javascript ...

Is there a way to customize the appearance of a MUI5 Tooltip using emotion?

I went through the information in this Stack Overflow post and experimented with the styled method. The code snippet I used is as follows: import * as React from 'react'; import { styled } from '@mui/material/styles'; import Tooltip, { ...

Facing numerous "error TS1005" messages when performing a gulp build due to node_modules/@types/ [prop types] and [react] index.d.ts with SPFx Webpart

I am currently in the process of developing a custom spfx webpart that includes a feature to display link previews. In order to achieve this functionality, I integrated this specific library. However, I encountered some challenges during the implementation ...

Generate ES6 prototypes using TypeScript

Is it possible to enhance specific class methods in TypeScript by making them prototypes, even when the target is ES6? Additionally, can a specific class be configured to only produce prototypes? Consider the following TypeScript class: class Test { ...

Decorators in Angular 9 do not have the capability to support function expressions

Currently, I am working with Angular 9 and facing an issue while generating dynamic routes values during runtime. I have implemented a ComplexUrlRouter to achieve this functionality and integrated it into my Route configuration. However, I encountered the ...

`How can I implement user authentication with Next.js using a Node.js server?`

Currently, I have integrated next auth for user authentication in my Next.js application. However, the endpoints are located on a Node.js server while the logic for next auth is contained in the api/auth/[...nextauth] file. I am now facing the challenge of ...

Tips for Uploading Large Images to Backend API in Next.js

As I work on building my portfolio using NextJS, I encountered an issue with the Project Functionality. When converting images to base64 and sending them to an API for uploading on Cloudinary, everything runs smoothly as long as the total size of the req ...

A guide on assigning a state variable to a dynamically generated component within a React application

I need to display user data from an array and have a button for each watchlist that deletes it. Although the backend is set up with a function deleteWatchlist, I am facing an issue in setting the state of the watchlistName for each watchlist after mapping ...

Enhancing JavaScript with TypeScript: implementing functional mixins

I'm in the process of creating functional mixins using TypeScript. Below is the code I have written so far: const flying = (o: object) => { let isFlying = false; return Object.assign({}, o, { fly() { isFlying = true; return thi ...

Guide on utilizing a provider's variable in another provider within Ionic 2/3

In my code, I have a boolean variable called isConnection that is used to monitor network connection status. This variable is defined in a provider named 'network' and can be set to either true or false in different functions. Now, I need to acc ...

Enhancing Material UI v4 Themes using TypeScript

I am attempting to implement my own custom palette option in the theme section, but I am struggling with how to do the augmentation part using TypeScript. So far, I have created a file named "material-ui.d.ts" and inside it, I only have: import { PaletteO ...

NextJS makes it simple to link to an external site by using the built-in

I find myself stuck on what seems like a simple question, but I can't figure it out. How do I accomplish this? I've searched in several different ways for an answer to this question but haven't been able to find a clear solution. I'm w ...