Не удается найти модуль при развертывании приложения angular на heroku - PullRequest
0 голосов
/ 14 января 2020

Когда я запускаю его локально на локальном хосте, при запуске ng build --aot --prod проблем не возникает, но при развертывании на heroku он больше не распознает импорт компонента. Предполагалось, что в пакете могут отсутствовать зависимости. json, но я добавил все зависимости от devDependencies, поскольку в этом руководстве было предложено https://itnext.io/how-to-deploy-angular-application-to-heroku-1d56e09c5147.

Я посмотрел и попробовал много решения, которые я нашел, но пока ничего не получалось. Я действительно не знаю, с чего начать отладку этой проблемы, любая помощь будет принята с благодарностью.

edit: отказался от попыток исправить это, поэтому я просто создал новый проект angular и просто скопировал поверх sr c и изменение нового пакета приложений. json и теперь он работает, так что я не знаю, в чем заключалась проблема, потому что я был слишком расстроен, чтобы попытаться разобраться.

пакет. json :

  {
    "name": "event-app",
      "version": "0.0.0",
      "scripts": {
        "ng": "ng",
        "start": "node server.js",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e",
        "postinstall": "ng build --aot --prod"
      },
      "private": true,
      "dependencies": {
        "@angular/animations": "~8.2.14",
        "@angular/cli": "~8.3.20",
        "@angular/common": "~8.2.14",
        "@angular/compiler": "~8.2.14",
        "@angular/compiler-cli": "~8.2.14",
        "@angular/core": "~8.2.14",
        "@angular/forms": "~8.2.14",
        "@angular/platform-browser": "~8.2.14",
        "@angular/platform-browser-dynamic": "~8.2.14",
        "@angular/router": "~8.2.14",
        "@material-ui/pickers": "^3.2.8",
        "@ng-bootstrap/ng-bootstrap": "^5.1.4",
        "bootstrap": "^4.4.1",
        "dotenv": "^8.2.0",
        "enhanced-resolve": "^4.1.1",
        "express": "^4.17.1",
        "jquery": "^3.4.1",
        "rxjs": "~6.4.0",
        "rxjs-compat": "^6.5.3",
        "tree-kill": "^1.2.2",
        "tslib": "^1.10.0",
        "typescript": "~3.5.3",
        "zone.js": "~0.9.1"
      },
      "devDependencies": {
        "@angular-devkit/build-angular": "^0.803.22",
        "@angular/language-service": "~8.2.14",
        "@angular/cli": "~8.3.20",
        "@angular/compiler-cli": "~8.2.14",
        "@types/jasmine": "~3.3.8",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "~8.9.4",
        "codelyzer": "^5.0.0",
        "jasmine-core": "~3.4.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~4.1.0",
        "karma-chrome-launcher": "~2.2.0",
        "karma-coverage-istanbul-reporter": "~2.0.1",
        "karma-jasmine": "~2.0.1",
        "karma-jasmine-html-reporter": "^1.4.0",
        "protractor": "~5.4.0",
        "ts-node": "~7.0.0",
        "tslint": "~5.15.0",
        "typescript": "~3.5.3"
      },
      "engines": {
        "node": "10.16.3",
        "npm": "6.9.0"
      }
    }

CLI:

PS C:\Users\Frank\Documents\GitHub\angular-test\lostnFound> git push heroku master 
Enumerating objects: 223, done.
Counting objects: 100% (223/223), done.
Delta compression using up to 8 threads
Compressing objects: 100% (218/218), done.
Writing objects: 100% (223/223), 174.83 KiB | 3.43 MiB/s, done.
Total 223 (delta 117), reused 0 (delta 0)
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=false
remote:        NODE_VERBOSE=false
remote:
remote: -----> Installing binaries
remote:        engines.node (package.json):  10.16.3
remote:        engines.npm (package.json):   6.9.0
remote:
remote:        Resolving node version 10.16.3...
remote:        Downloading and installing node 10.16.3...
remote:        npm 6.9.0 already installed with node
remote:        
remote: -----> Restoring cache
remote:        Caching has been disabled because NODE_MODULES_CACHE=false
remote:        
remote: -----> Installing dependencies
remote:        Installing node modules (package.json + package-lock)
remote:        
remote:        > core-js@2.6.11 postinstall /tmp/build_88602988e915eee083edd9f087d17ec5/node_modules/babel-runtime/node_modules/core-js
remote:        > node -e "try{require('./postinstall')}catch(e){}"
remote:
remote:        
remote:        > core-js@3.2.1 postinstall /tmp/build_88602988e915eee083edd9f087d17ec5/node_modules/core-js
remote:        > node scripts/postinstall || echo "ignore"
remote:
remote:        
remote:        > core-js-pure@3.4.7 postinstall /tmp/build_88602988e915eee083edd9f087d17ec5/node_modules/core-js-pure
remote:        > node -e "try{require('./postinstall')}catch(e){}"
remote:
remote:        
remote:        > core-js@2.6.10 postinstall /tmp/build_88602988e915eee083edd9f087d17ec5/node_modules/karma/node_modules/core-js
remote:        > node postinstall || echo "ignore"
remote:
remote:        
remote:        > @angular/cli@8.3.20 postinstall /tmp/build_88602988e915eee083edd9f087d17ec5/node_modules/@angular/cli
remote:        > node ./bin/postinstall/script.js
remote:
remote:        
remote:        > event-app@0.0.0 postinstall /tmp/build_88602988e915eee083edd9f087d17ec5
remote:        > ng build --aot --prod
remote:
remote:        
remote:        ERROR in src/app/app-routing.module.ts:3:32 - error TS2307: Cannot find module './posts/posts.component'.
remote:
remote:        3 import { PostsComponent } from './posts/posts.component';
remote:                                         ~~~~~~~~~~~~~~~~~~~~~~~~~
remote:        src/app/app.module.ts:10:32 - error TS2307: Cannot find module './posts/posts.component'.
remote:
remote:        10 import { PostsComponent } from './posts/posts.component';
remote:                                          ~~~~~~~~~~~~~~~~~~~~~~~~~
remote:
remote:        ERROR in src/app/app.module.ts(23,5): Error during template compile of 'AppModule'
remote:          Could not resolve ./posts/posts.component relative to [object Object]..
remote:        src/app/app-routing.module.ts(11,25): Error during template compile of 'AppRoutingModule'
remote:          Could not resolve ./posts/posts.component relative to [object Object]..
remote:        src/app/app-routing.module.ts(14,30): Error during template compile of 'AppRoutingModule'
remote:          Could not resolve ./posts/posts.component relative to [object Object]..
remote:        Couldn't resolve resource ./posts.component.css relative to /tmp/build_88602988e915eee083edd9f087d17ec5/src/app/Posts/posts.component.ts
remote:
remote:        npm ERR! code ELIFECYCLE
remote:        npm ERR! errno 1
remote:        npm ERR! event-app@0.0.0 postinstall: `ng build --aot --prod`
remote:        npm ERR! Exit status 1
remote:        npm ERR!
remote:        npm ERR! Failed at the event-app@0.0.0 postinstall script.
remote:        npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:        
remote:        npm ERR! A complete log of this run can be found in:
remote:        npm ERR!     /tmp/npmcache.PK91A/_logs/2020-01-14T02_44_41_751Z-debug.log
remote: 
remote: -----> Build failed
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:
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...