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

Angular correctly displaying specific array items within button elements

I am facing an issue with my dashboard where I have 4 items in an array and 4 buttons on display. My goal is to assign each item with a specific button, but currently, it shows 4 buttons for each "hero" resulting in a total of 16 buttons. I have tried usin ...

JavaScript Equivalent to C#'s BinaryReader.ReadString() Function

Currently, I am in the process of translating C# code into JavaScript. While transferring multiple datatypes from this file to matching functionalities found in various JavaScript libraries was relatively smooth, there is one specific function that seems t ...

Assigning a Value to a Dropdown Menu in Angular

I have some JSON data that contains a True/False value. Depending on whether it is true or false, I want a specific option in a Select Dropdown to be automatically selected. This is the HTML code using Angular 16: <select name="reportNo" id=& ...

Is it possible to create cloud functions for Firebase using both JavaScript and TypeScript?

For my Firebase project, I have successfully deployed around 4 or 5 functions using JavaScript. However, I now wish to incorporate async-await into 2 of these functions. As such, I am considering converting these specific functions to TypeScript. My conc ...

Shall we delve into Nextjs' shallow routing for tabs?

Implement a tabs component that seamlessly integrates with the router.query state useEffect(() => { let found = false; if (currentTab !== 'leads') { router.push(`${id}?tab=${currentTab}`, undefined, { ...

Resolve ESLint errors in _document.tsx file of next.js caused by Document<any> and ctx.renderPage = () with TypeScript usage

maxbause took the initiative to create a comprehensive boilerplate project for Next.js, complete with GraphQL and styled components in TypeScript. Check out the project here However, upon integrating ESLint into the project, I encountered several warning ...

Frontend excel file download facilitated by excel4node backend integration

Although this question has been asked previously, I am struggling to make it work. The backend is sending the file using wb.write('filename.xlsx', res), but on the frontend, I only receive an object response. How can I ensure that the browser dow ...

Unable to locate the Next Js context

import { createContext, ReactNode, useState } from 'react'; import { MenuItem } from '../interfaces/menu.interfaces'; import { TopLevelCategory } from '../interfaces/page.interface'; export interface IAppContext { menu: M ...

Using TypeScript and controllerAs with $rootScope

I am currently developing an application using Angular 1 and Typescript. Here is the code snippet for my Login Controller: module TheHub { /** * Controller for the login page. */ export class LoginController { static $inject = [ ...

Changing the global type in TypeScript

Currently, I am incorporating two third-party TypeScript libraries into my project. Interestingly, both of these libraries expose a global variable with the same name through the Window interface. However, they offer different methods for interacting with ...

What is the best way to retry an action stream observable in Angular/RxJS after it fails?

Kindly disregard the variable names and formatting alterations I've made. I've been attempting to incorporate RxJS error handling for an observable that triggers an action (user click) and then sends the request object from our form to execute a ...

Creating a spy object in Jasmine for the forEach method of router.events

I have been attempting to create a test case for a component in an application and am having trouble with the constructor. Here is how it looks: constructor(private router: Router, public dialog: MatDialog, private tlsApiServi ...

What is the syntax for declaring a variable as a string or a function with parameters?

Is it possible to define a variable in TypeScript like a string or as a Function, but with specific parameters? I am aware of how to define a string actionGetData: string; and a function actionLoaded?(event: any, ui: any): void;, but when I try to define ...

Navigating to the main directory in Angular 2

I am currently diving into the world of Angular 2 and attempting to create my very first application. I am following a tutorial from Barbarian Meets Coding to guide me through the process. Following the steps outlined in the tutorial, I have set up my appl ...

What to do when encountering the error "Uncaught (in promise) SyntaxError: Unexpected end of JSON input"?

While signing in to my website from localhost is successful, I encounter an issue when trying to do the same from my production build. The login attempt from the prod build (hosted on Vercel) does not post to , but instead goes to . I am perplexed by the a ...

Is there a way to determine if a React functional component has been displayed in the code?

Currently, I am working on implementing logging to track the time it takes for a functional component in React to render. My main challenge is determining when the rendering of the component is complete and visible to the user on the front end. I believe t ...

Having trouble with triggers: Unable to locate the module 'csv-parse/sync' for parsing

Currently, I am utilizing Firebase functions to create an API that is capable of parsing CSV files. However, whenever I attempt to utilize csv-parse/sync instead of csv-parse, my deployment to Firebase Functions encounters a failure with the subsequent er ...

"Alert: Cautionary notification when utilizing server action in the latest version of Next.js

I keep receiving this warning message in my server-side console while using server actions: Warning: Cannot specify an encType or method for a form that specifies a function as the action. React provides those automatically and they will be overridden. Ho ...

Building a Nextjs app within a monorepo poses challenges when utilizing shared libraries

In my monorepo using pnpm, I have a backend along with 3 nextjs apps that connect to the backend within the same monorepo. /packages /admin -> nextjs /operator -> nextjs /backend -> nestjs /shared -> shared l ...

Error: Vue Prop is undefined and cannot be utilized within a v-for loop when using TypeScript and decorators

Hey there, I'm currently utilizing Vue along with typescript and facing an issue with props in v-for where it's not rendering anything. Check out the code snippet below for reference I've experimented with computed props, setting default va ...