当我尝试在Heroku中构建NodeJS应用程序时,Typescript上出现错误TS2307



当我执行命令git push heroku master时,在构建步骤中会返回一个错误。

然而,在本地环境中,使用相同版本的NodeJS和NPM不会发生错误。该系统也100%由自动化测试覆盖,并且没有任何测试返回错误。

如何复制此问题:

git clone https://github.com/felinto-dev/clean-node-api-ts
cd clean-node-api-ts
git init -y
git push heroku master

错误日志:

remote: Compressing source files... done.
remote: Building source:
remote: 
remote: -----> Node.js app detected
remote:        
remote: -----> Creating runtime environment
remote:
remote:        NPM_CONFIG_LOGLEVEL=error
remote:        NODE_ENV=production
remote:        NODE_MODULES_CACHE=true
remote:        NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  12.x
remote:        engines.npm (package.json):   unspecified (use default)
remote:
remote:        Resolving node version 12.x...
remote:        Downloading and installing node 12.18.2...
remote:        Using default npm version: 6.14.5
remote:        
remote: -----> Restoring cache
remote:        - node_modules
remote:
remote: -----> Installing dependencies
remote:        Installing node modules (package.json)
remote:        added 1 package from 1 contributor, updated 1 package and audited 1020 packages in 8.612s
remote:        
remote:        52 packages are looking for funding
remote:          run `npm fund` for details
remote:
remote:        found 0 vulnerabilities
remote:
remote:        
remote: -----> Build
remote:        Running build
remote:        
remote:        > clean-node-api@1.1.0 build /tmp/build_4fc3d9921e6aaa1c4e6d21786f8596fe
remote:        > rm -rf dist && tsc
remote:
remote:        src/data/protocols/db/account/add-account-repository.ts(2,30): error TS2307: Cannot find module '../../../../domain/models/account' or its corresponding type declarations.
remote:        src/data/protocols/db/account/load-account-by-email-repository.ts(1,30): error TS2307: Cannot find module '../../../../domain/models/account' or its corresponding type declarations.
remote:        src/data/usecases/add-account/db-add-account-protocols.ts(2,15): error TS2307: Cannot find module '../../../domain/models/account' or its corresponding type declarations.
remote:        src/data/usecases/add-account/db-add-account.spec.ts(2,35): error TS2305: Module '"./db-add-account-protocols"' has no exported member 'AccountModel'.
remote:        src/data/usecases/add-account/db-add-account.ts(1,39): error TS2305: Module '"./db-add-account-protocols"' has no exported member 'AccountModel'.
remote:        src/data/usecases/authentication/db-authentication-protocols.ts(1,15): error TS2307: Cannot find module '../../../domain/models/account' or its corresponding type declarations.
remote:        src/data/usecases/authentication/db-authentication.spec.ts(3,3): error TS2305: Module '"./db-authentication-protocols"' has no exported 
member 'AccountModel'.
remote:        src/domain/usecases/add-account.ts(1,30): error TS2307: Cannot find module '../models/account' or its corresponding type declarations.  
remote:        src/infra/db/mongodb/account/account-mongo-repository.ts(3,30): error TS2307: Cannot find module '../../../../domain/models/account' or 
remote:
remote:        We're sorry this build is failing! You can troubleshoot common issues here:
remote:        https://devcenter.heroku.com/articles/troubleshooting-node-deploys
remote:
remote:        Some possible problems:
remote:
remote:        - A module may be missing from 'dependencies' in package.json
remote:          https://devcenter.heroku.com/articles/troubleshooting-node-deploys#ensure-you-aren-t-relying-on-untracked-dependencies
remote:
remote:        Love,
remote:        Heroku
remote:
remote:  !     Push rejected, failed to compile Node.js app.
remote:
remote:  !     Push failed
remote: Verifying deploy...
remote:
remote: !       Push rejected to felinto-clean-node-api-ts.
remote:
To https://git.heroku.com/felinto-clean-node-api-ts.git
! [remote rejected] master -> master (pre-receive hook declined)
! [remote rejected] 1.0.0 -> 1.0.0 (pre-receive hook declined)
! [remote rejected] 1.1.0 -> 1.1.0 (pre-receive hook declined)
error: failed to push some refs to 'https://git.heroku.com/felinto-clean-node-api-ts.git'

在您的package.json文件中尝试此操作"scripts": { "build": "tsc", "heroku-postbuild": "npm run build", "start": "node build/app.js" },

最新更新