简体   繁体   中英

I am trying to deploy my node.js application into heroku

I am trying to deploy my node.js application into Heroku but when I try to push to Heroku branch my project I get:

remote: node_modules/@types/jsdom/base.d.ts:192:18 - error TS2411: Property '["Infinity"]' of type 'number' is not assignable to 'number' index type 'Window'.
remote: 
remote: 192         readonly ["Infinity"]: number;
remote:                      ~~~~~~~~~~~~
remote: node_modules/@types/jsdom/base.d.ts:193:18 - error TS2411: Property '["NaN"]' of type 'number' is not assignable to 'number' index type 'Window'.
remote: 
remote: 193         readonly ["NaN"]: number;
remote:                      ~~~~~~~
remote: 
remote:        Found 2 error(s).

Node.Js version: v17.0.1 Npm version: 8.1.0

I developed this project with the nest.js framework, actually when I start in the local environment without problems.

Even I am getting the same error.

Using option skipLibCheck: true in tsconfig.json might be a temporary solution.

The underlying problem is that a transitive dependency was updated recently and that update isn't compatible with typescript. Also, I'm guessing aren't using a lock file, which if this is the case is less than ideal.

For my nestjs project the problem was with a transitive dependency of jest. If you are using jest, see this github discussion to follow along and get updates as well as maybe get some tips on how to workaround it if you can't start using a lock file immediately https://github.com/facebook/jest/issues/12098 (There seems to be a PR opened up in the underlying repo, but it might take some time to get approved and updated to npm's registry. https://github.com/DefinitelyTyped/DefinitelyTyped/pull/57432 )

If you don't have your package-lock.json file committed in your git repository you should add it. Heroku uses either package.json or package-lock.json to install your dependencies for you and if you want reproducible builds you should definitely use package-lock.json. If you have a package-lock.json file locally and it is currently git ignored, you can remove the entry in your.gitignore file.

See Heroku's docs for more info on how it handles package-lock.json: https://devcenter.heroku.com/articles/nodejs-support#package-installation

Heroku uses the lockfiles, either the package-lock.json or yarn.lock, to install the expected dependency tree, so be sure to check those files into git to ensure the same dependency versions across environments. If you are using npm, Heroku will use npm ci to set up the build environment.

This is still an issue for me with Jest v29. Microsoft even does some crazy workaround to fix this issue.

Revert Jest and related dependencies to v27.3.1 until fixed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM