Requesting Typescript dependency on build time

Expected result: build correctly as it runs in local. Typescript added as a dependency and dev-dependency already. Cannot seem to be able to find it on build time.

Hi,

I am running a Nextjs site. My build keeps crashing and requesting to add typescript to the dependencies, although it is listed and installed as a dependency:

"typescript": "^4.8.4"

I have already tried adding it as a dependency, as a dev dependency, as well as declaring them them both. The build runs perfectly locally.

this is the error message:

" info - Linting and checking validity of types…
17:30:01.814 It looks like you’re trying to use TypeScript but do not have the required package(s) installed.
17:30:01.814
17:30:01.814 Please install typescript by running:
17:30:01.814
17:30:01.814 npm install --save-dev typescript
17:30:01.814
17:30:01.815 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).
17:30:01.815
17:30:01.864 Failed: build command exited with code: 1
17:30:04.972 Failed: an internal error occurred"

Thanks!!

Do you have a NODE_ENV set in your env vars at all?

And if you don’t already, can you try setting a modern NODE_VERSION env var to something like 16?

Hi, thanks for the quick answer. My env variables already include NODE_ENV (production) and NODE VERSION (16.13):

Can you share a full build log and if possible a minimal repo to reproduce the issue please?

Here goes the log: https://www.dropbox.com/s/4j7tqd685vhjh3m/becario.6fda4c4b-7c1f-4748-9f37-7534e4926f6d.log?dl=0

A mini repo would be more complex, but if the log does not help I can think how to provide access.

Well, I managed to workaround it:

  • Switched from npm to yarn
  • remove and update the modules

Yarn gives much information about what was going on…

  • somehow it is looking for @storybook/react and its types in the dependencies, even if they are already declared as dev-dependencies
  • “Transforming async functions to the configured target environment (“es5”) is not supported yet”, “Transforming destructuring to the configured target environment (“es5”) is not supported yet”…
  • changed target in compiler tsconfig to es6 (crossing fingers it does not have a side effect)

It is building it now. Apparently all okay. Hope it helps!

1 Like

Same issue. I got it working. I did some upgrades, but specifically what made it finally work was removing the one env var of: NODE_ENV=production. After this env removal, the same branch built.