Error saying typescript not installed (but it is)

Hi, I’m using Next on Netlify to deploy a website but getting the following error

It looks like you’re trying to use TypeScript but do not have the required package(s) installed.

3:16:54 PM: Please install typescript by running:

3:16:54 PM: yarn add --dev typescript

3:16:54 PM: If you are not trying to use TypeScript, please remove the tsconfig.json file from your package root (and any TypeScript files in your pages directory).

But I do have it installed

"typescript": "^4.3.2",

@types/node”: “^15.6.1”,

Hi there, @slightly-askew :wave:

Welcome to the Netlify Forums! Sorry to hear you are encountering an unexpected behaviour. We will need a bit more information to dig in here. Can you please share your site name and your repo?

Hey @hillary :wave:

Thank you!
Repo is https://github.com/AO-Print-Mail/website
Site name is eloquent-haibt-d9ac20
Latest deploy is at https://app.netlify.com/sites/eloquent-haibt-d9ac20/deploys/60b451ae54d5a60007d366c6

I did manage to deploy it with netlify-cli but not CI :slight_smile:

Hi @slightly-askew

I notice you have "typescript": "^4.3.2", listed under devDependencies in your package.json but not listed under dependencies.

Thanks for the suggestion, coelmay!

The instruction in the error message does include the --dev flag, so a devDependency should work fine? I’m not sure that there would be any difference in this context?

devDependencies are those required as part of the development workflow, as opposed to dependencies which are required when running your code (in-depth explanations Types of dependencies | Yarn )

Hi @slightly-askew

I see you’ve also raised a helpdesk ticket regarding the issue. We’d be following up there.

Hi @hrishikesh We’re currently also experiencing this issue. Was a fix found to resolve this? Thanks

Hi @AlfieB,

In the above case, it was because typescript was listed in devDependencies instead of dependencies. Is that the case with you too?

I have a project that was deploying fine with a single .ts file used as a middleware. The tsconfig.json was present for the last couple dozen builds with no issue. In the most recent set of deploys they have failed with the same error at the beginning of this thread. I followed the suggestions of installing the dependancies not just as devdependancies but both. Still no luck. Builds locally fine with no issues. Are there any other suggestions?

Could we see a repo with reproduction?

For anyone landing here from a search: in my case, I had set a NODE_ENV=production environment variable in my deploy settings. Removing it caused the site to build with no issues.