angular / angular-cli

CLI tool for Angular
https://cli.angular.io
MIT License
26.76k stars 11.97k forks source link

Can't resolve '../../../@angular/core' #5868

Closed zihangfeng closed 7 years ago

zihangfeng commented 7 years ago

Bug Report

I am working on an angular2 project as the version and the dependencies imply that. The project itself running locally works fine. However, when I try the command in the Command I use to run section, it produces the error in the The log given by the failure section. However I could actually set the aot to false in the command section to make everything works perfectly as I have seen people done that. The problem for that solution would kill the performance. I need to keep the aot set to true. Any help would be highly appreciated.

Versions.

Command I use to run.

docker run --rm @Docker_image \
                            -v host_path:/docker_path \
                             npm run ng \
                             -- build --environment staging \
                             --target production \
                             --aot true \
                             --output-path "docker_path" \
                             --output-hashing all \
                             --base-href /our_project/

Dependencies

    "dependencies": {                                                                                                                                        
       "@angular/animations": "^4.0.1",                                                                                                                       
      "@angular/common": "^4.0.1",                                                                                                                           
      "@angular/compiler": "^4.0.1",                                                                                                                         
      "@angular/core": "^4.0.1",                                                                                                                             
      "@angular/flex-layout": "^2.0.0-beta.7",                                                                                                               
      "@angular/forms": "^4.0.1",                                                                                                                            
      "@angular/http": "^4.0.1",                                                                                                                             
      "@angular/material": "^2.0.0-beta.2",                                                                                                                  
      "@angular/platform-browser": "^4.0.1",                                                                                                                 
      "@angular/platform-browser-dynamic": "^4.0.1",                                                                                                         
      "@angular/router": "^4.0.1",                                                                                                                           
      "core-js": "^2.4.1",                                                                                                                                   
      "font-awesome": "^4.7.0",                                                                                                                              
      "hammerjs": "^2.0.8",                                                                                                                                  
      "primeng": "^2.0.3",                                                                                                                                   
      "rxjs": "^5.3.0",                                                                                                                                      
      "zone.js": "^0.7.8" 
  },
   "devDependencies": {                                                                                                                                     
      "@angular/cli": "1.0.0-rc.1",                                                                                                                          
      "@angular/compiler-cli": "^2.4.0",                                                                                                                     
      "@types/jasmine": "2.5.38",                                                                                                                            
      "@types/node": "~6.0.60",                                                                                                                              
      "codelyzer": "~2.0.0",                                                                                                                                 
      "jasmine-core": "~2.5.2",                                                                                                                              
      "jasmine-spec-reporter": "~3.2.0",                                                                                                                     
      "karma": "~1.4.1",                                                                                                                                     
      "karma-chrome-launcher": "~2.0.0",                                                                                                                     
      "karma-cli": "~1.0.1",                                                                                                                                 
      "karma-jasmine": "~1.1.0",                                                                                                                             
      "karma-jasmine-html-reporter": "^0.2.2",                                                                                                               
      "karma-coverage-istanbul-reporter": "^0.2.0",                                                                                                          
      "protractor": "~5.1.0",                                                                                                                                
      "ts-node": "~2.0.0",                                                                                                                                   
      "tslint": "~4.5.0",                                                                                                                                    
      "typescript": "~2.0.0"                                                                                                                                 
    }   

The log given by the failure.

ERROR in ./src/$$_gendir/app/app.module.ngfactory.ts Module not found: Error: Can't resolve '../../../@angular/core' in '/app/src/$$_gendir/app' @ ./src/$$_gendir/app/app.module.ngfactory.ts 12:0-50 @ ./src/main.ts @ multi ./src/main.ts

and more error follows

ahelord commented 7 years ago

what is fix? @zihangfeng

zihangfeng commented 7 years ago

@aheload the typescript was not compatible with angular 4. If you change the typescript to the latest version which will be compatible with angular 4, it might cause the the aot to have problem too. So change the typescript to match the angular 4 first. If that does not help, roll back to angular 2 with typescript 2.0.10

ahelord commented 7 years ago

@zihangfeng Friend, I have these dependencies. { "name": "centros", "version": "0.0.0", "license": "MIT", "angular-cli": {}, "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e",

}, "private": true, "dependencies": { "@angular/common": "2.4.8", "@angular/compiler": "2.4.8", "@angular/compiler-cli": "2.4.8", "@angular/core": "2.4.8", "@angular/forms": "2.4.8", "@angular/http": "2.4.8", "@angular/platform-browser": "2.4.8", "@angular/platform-browser-dynamic": "2.4.8", "@angular/router": "3.4.8", "body-parser": "1.15.2", "concurrently": "3.4.0", "cookie-parser": "1.4.3", "cookie-session": "2.0.0-alpha.2", "core-js": "2.4.1", "dateformat": "2.0.0", "emailjs": "1.0.8", "express": "4.13.4", "font-awesome": "4.7.0", "fullcalendar": "3.2.0", "intl": "1.2.5", "jade": "1.11.0", "jquery": "3.1.1", "massive": "2.5.0", "moment": "2.17.1", "morgan": "1.7.0", "node-sass": "3.13.1", "nodemon": "1.11.0", "oauth2orize": "1.7.0", "passport": "0.3.2", "passport-http": "0.3.0", "passport-http-bearer": "1.0.1", "pg": "6.1.5", "pg-hstore": "2.3.2", "primeng": "1.1.4", "rxjs": "5.2.0", "sequelize": "3.30.4", "sequelize-auto": "0.4.27", "sequelize-cli": "2.7.0", "serve-favicon": "2.3.0", "zone.js": "0.7.7" }, "devDependencies": { "@angular/cli": "^1.0.4", "@angular/compiler-cli": "2.4.8", "@types/jasmine": "2.5.38", "@types/jquery": "2.0.40", "@types/node": "6.0.63", "chai": "3.5.0", "codelyzer": "2.0.1", "cross-env": "4.0.0", "jasmine-core": "2.5.2", "jasmine-spec-reporter": "3.2.0", "karma": "1.4.1", "karma-chrome-launcher": "2.0.0", "karma-cli": "1.0.1", "karma-coverage-istanbul-reporter": "0.2.0", "karma-jasmine": "1.1.0", "karma-jasmine-html-reporter": "0.2.2", "karma-phantomjs-launcher": "1.0.2", "lite-server": "2.3.0", "mocha": "3.2.0", "protractor": "5.1.0", "supertest": "3.0.0", "ts-node": "2.0.0", "tslint": "4.4.2", "typescript": "2.0.10" } }

I have errors finding @angular/core and styles because it does not find the path, this happens after doing update

zihangfeng commented 7 years ago

I don't know about the issue for the angular/core. For the styles, you need to put the path in the styles.css file in your src folder

ahelord commented 7 years ago

@zihangfeng This is my style.css file, import the additional CSS but it leaves 404 when requesting the files `/ Library PrimeNg / @import url("../node_modules/primeng/resources/primeng.min.css");

/ Library PrimeNg Omega Template / @import url("../node_modules/primeng/resources/themes/omega/theme.css");

/Library CSS Font Awesome/ @import url('../node_modules/font-awesome/css/font-awesome.min.css');

/General CSS/ @import url('./app/app.style.css');

/Dashboard CSS/ @import url('./app/dashboard/styles/dashboard.style.css');`

angular-automatic-lock-bot[bot] commented 5 years ago

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.