angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Versions of @angular/compiler-cli and typescript could not be determined.

Open astalegale opened this issue 9 years ago • 42 comments

Bug Report or Feature Request (mark with an x)

- [x] bug report -> please search issues before submitting
- [ ] feature request

Versions.

ng 1.5.0 node 8.9.0 npm 5.5.1 yarn 1.3.2 visual studio code 1.17.2

Repro steps.

run ng serve or ng serve -aot

The log given by the failure.

Versions of @angular/compiler-cli and typescript could not be determined. The most common reason for this is a broken npm install.

Please make sure your package.json contains both @angular/compiler-cli and typescript in devDependencies, then delete node_modules and package-lock.json (if you have one) and run npm install again.

Desired functionality.

Mention any other details that might be useful.

here my package.json

{
    "name": "migate",
    "version": "0.1.0",
    "license": "MIT",
    "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "lint": "ng lint",
        "e2e": "ng e2e"
    },
    "private": true,
    "dependencies": {
        "@angular/animations": "^5.0.0",
        "@angular/common": "^5.0.0",
        "@angular/core": "^5.0.0",
        "@angular/forms": "^5.0.0",
        "@angular/platform-browser": "^5.0.0",
        "@angular/platform-browser-dynamic": "^5.0.0",
        "@angular/router": "^5.0.0",
        "bootstrap": "^4.0.0-beta.2",
        "core-js": "^2.5.1",
        "global": "^4.3.2",
        "jquery": "^3.2.1",
        "json-typescript-mapper": "^1.1.3",
        "popper.js": "^1.12.6",
        "roboto-fontface": "^0.8.0",
        "rxjs": "^5.5.2",
        "typescript-string-operations-ng4": "^0.1.0",
        "zone.js": "^0.8.18"
    },
    "devDependencies": {
        "@angular/cli": "^1.5.0",
        "@angular/compiler": "^5.0.0",
        "@angular/compiler-cli": "^5.0.0",
        "@angular/language-service": "^5.0.0",
        "@types/jasmine": "~2.6.2",
        "@types/jasminewd2": "~2.0.3",
        "@types/node": "~8.0.47",
        "codelyzer": "~4.0.0",
        "jasmine-core": "~2.8.0",
        "jasmine-spec-reporter": "~4.2.1",
        "karma": "~1.7.1",
        "karma-chrome-launcher": "~2.2.0",
        "karma-cli": "~1.0.1",
        "karma-coverage-istanbul-reporter": "^1.3.0",
        "karma-jasmine": "~1.1.0",
        "karma-jasmine-html-reporter": "^0.2.2",
        "protractor": "~5.2.0",
        "ts-node": "~3.3.0",
        "tslint": "~5.8.0",
        "typescript": "~2.4.0",
        "webpack": "^3.8.1",
        "webpack-sources": "^1.0.1"
    }
}

astalegale avatar Nov 08 '17 17:11 astalegale

+1 I am also having same problem and tried different things but nothing worked

appdevchicago avatar Nov 08 '17 22:11 appdevchicago

Can you run both a yarn list --pattern typescript and yarn list --pattern @angular/compiler-cli and report back with the output?

Does everything work when using npm or do you receive the same error?

clydin avatar Nov 08 '17 23:11 clydin

Do you have environment variable NODE_ENV=production like I had? Clear this value, delete folder node_modules and file package-lock.json, rerun npm install, reassign the NODE_ENV and you should be ok. See also npm issues

ghost avatar Nov 09 '17 14:11 ghost

NOVE_ENV=production is what got me as well. I spent an hour and a half trying different things before I found your comment @frigel. This means the angular tutorial is hopelessly broken for anyone with that environment variable. I got lucky.

ghost avatar Nov 10 '17 17:11 ghost

I don't have NODE_ENV=production and have the same error

Jin-K avatar Nov 10 '17 18:11 Jin-K

I also don't have NODE_ENV=production.

In environment.ts from a sample project I'm working in, I see

export const environment = { production: false, and even in environment.prod.ts I went ahead and set the value to false.

From the shell, I entered export NODE_ENV=development (probably not necessary?) rm -rf node_modules package.json.lock npm install npm start

I still have the same error.

chrisxpagan avatar Nov 10 '17 22:11 chrisxpagan

Could you check that your "@angular/compiler" in your dependencies is compatible with angular/cli version:

https://stackoverflow.com/a/47328497/2633707

dalidovski avatar Nov 16 '17 11:11 dalidovski

Having the same trying to deploy my app to heroku. This is what part of my heroku push log says, sorry guys, this is verbose

C:\Users\evanc\myTaskList> git push heroku master Counting objects: 116, done.Delta compression using up to 2 threads.Compressing objects: 100% (111/111), done. Writing objects: 100% (116/116), 97.97 KiB | 0 bytes/s, done. Total 116 (delta 44), 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: NPM_CONFIG_PRODUCTION=true remote: NODE_VERBOSE=false remote: NODE_ENV=production remote: NODE_MODULES_CACHE=true remote: remote: -----> Installing binariesremote: engines.node (package.json): 8.9.1 remote: engines.npm (package.json): 5.5.1 remote:remote: Resolving node version 8.9.1... remote: Downloading and installing node 8.9.1...remote: npm 5.5.1 already installed with node remote:remote: -----> Restoring cacheremote: Skipping cache restore (not-found) remote:remote: -----> Building dependencies remote: Installing node modules (package.json + package-lock) remote: remote: > [email protected] install /tmp/build_fc6a62b6f884f1e42001e7869d499193/node_modules/node-sass remote: > node scripts/install.js remote: remote: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.6.1/linux-x64-57_binding.node remote: Download complete remote: Binary saved to /tmp/build_fc6a62b6f884f1e42001e7869d499193/node_modules/node-sass/vendor/linux-x64-57/binding.node remote: Caching binary to /app/.npm/node-sass/4.6.1/linux-x64-57_binding.node remote: remote: > [email protected] postinstall /tmp/build_fc6a62b6f884f1e42001e7869d499193/node_modules/webpack/node_modules/uglifyjs-webpack-plugin remote: > node lib/post_install.js remote: remote: remote: > [email protected] postinstall /tmp/build_fc6a62b6f884f1e42001e7869d499193/node_modules/node-sass remote: > node scripts/build.js remote: remote: Binary found at /tmp/build_fc6a62b6f884f1e42001e7869d499193/node_modules/node-sass/vendor/linux-x64-57/binding.node remote: Testing binary remote: Binary is fine remote: remote: > [email protected] postinstall /tmp/build_fc6a62b6f884f1e42001e7869d499193 remote: > ng build --aot -prod remote: remote: Versions of @angular/compiler-cli and typescript could not be determined. remote: The most common reason for this is a broken npm install. remote: remote: Please make sure your package.json contains both @angular/compiler-cli and typescript in remote: devDependencies, then delete node_modules and package-lock.json (if you have one) and remote: run npm install again. remote: npm ERR! code ELIFECYCLE remote: npm ERR! errno 2 remote: npm ERR! [email protected] postinstall: ng build --aot -prod remote: npm ERR! Exit status 2 remote: npm ERR! remote: npm ERR! Failed at the [email protected] 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! /app/.npm/_logs/2017-11-17T19_23_09_399Z-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: If you're stuck, please submit a ticket so we can help: remote: https://help.heroku.com/ 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 metasklist. remote: To https://git.heroku.com/metasklist.git ! [remote rejected] master -> master (pre-receive hook declined) error: failed to push some refs to 'https://git.heroku.com/metasklist.git'

this is my package.json

{ "name": "my-task-list", "version": "0.0.0", "engines": { "node": "8.9.1", "npm": "5.5.1" }, "license": "MIT", "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/cli": "1.5.0", "@angular/animations": "^5.0.0", "@angular/common": "^5.0.0", "@angular/compiler": "^5.0.0", "@angular/core": "^5.0.0", "@angular/forms": "^5.0.0", "@angular/http": "^5.0.0", "@angular/platform-browser": "^5.0.0", "@angular/platform-browser-dynamic": "^5.0.0", "@angular/router": "^5.0.0", "body-parser": "^1.18.2", "compression": "^1.7.1", "core-js": "^2.4.1", "cors": "^2.8.4", "dotenv": "^4.0.0", "express": "^4.16.2", "helmet": "^3.9.0", "mongodb": "^2.2.33", "rxjs": "^5.5.2", "zone.js": "^0.8.14" }, "devDependencies": { "@angular/cli": "1.5.0", "@angular/compiler-cli": "^5.0.0", "@angular/language-service": "^5.0.0", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "codelyzer": "~3.2.0", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "ts-node": "~3.2.0", "tslint": "~5.7.0", "typescript": "~2.4.2" } }

evanchime avatar Nov 17 '17 19:11 evanchime

I managed to solve my own problem, and have deployed to heroku. I put them two, @angular/compiler-cli and typescript together with @angular/cli in the dependencies. Don't know if this is the solution, @angular/compiler-cli and typescript together with @angular/cli in the same place, or I just had a stroke of luck

evanchime avatar Nov 17 '17 22:11 evanchime

after creating ng new Projectfoldername when i run "npm start" Im getting this error

Versions of @angular/compiler-cli and typescript could not be determined. The most common reason for this is a broken npm install.

Please make sure your package.json contains both @angular/compiler-cli and typescript in devDependencies, then delete node_modules and package-lock.json (if you have one) and run npm install again. npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! [email protected] start: ng serve npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the [email protected] start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\sudhakar reddy\AppData\Roaming\npm-cache_logs\2017-11-18T05_09_02_679Z-debug.log

I tried reinstalling i tried force install many ways but everything is not working I'm trying from Last 18 Hrs trying many ways to Overcome none of them is working. Anyone Help me

sudhakar216 avatar Nov 18 '17 05:11 sudhakar216

Have you done npm install -g @angular/cli@latest

evanchime avatar Nov 18 '17 09:11 evanchime

And you have @angular/cli, @angular/compiler-cli and typescript together in the dependencies or devDependencies, if you are on production or development respectively

evanchime avatar Nov 18 '17 10:11 evanchime

I did all those installations and I'm in development

Please suggest a sollution

sudhakar216 avatar Nov 18 '17 10:11 sudhakar216

all angular/cli ,angular/compiler and typescript are in my devDependencies

{ "name": "app", "version": "0.0.0", "license": "MIT", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^5.0.0", "@angular/common": "^5.0.0", "@angular/compiler": "^5.0.0", "@angular/core": "^5.0.0", "@angular/forms": "^5.0.0", "@angular/http": "^5.0.0", "@angular/platform-browser": "^5.0.0", "@angular/platform-browser-dynamic": "^5.0.0", "@angular/router": "^5.0.0", "core-js": "^2.4.1", "rxjs": "^5.5.2", "zone.js": "^0.8.14" }, "devDependencies": { "@angular/cli": "1.5.2", "@angular/compiler-cli": "^5.0.0", "@angular/language-service": "^5.0.0", "@types/jasmine": "~2.5.53", "@types/jasminewd2": "~2.0.2", "@types/node": "~6.0.60", "codelyzer": "~3.2.0", "jasmine-core": "~2.6.2", "jasmine-spec-reporter": "~4.1.0", "karma": "~1.7.0", "karma-chrome-launcher": "~2.1.1", "karma-cli": "~1.0.1", "karma-coverage-istanbul-reporter": "^1.2.1", "karma-jasmine": "~1.1.0", "karma-jasmine-html-reporter": "^0.2.2", "protractor": "~5.1.2", "ts-node": "~3.2.0", "tslint": "~5.7.0", "typescript": "^2.4.2" } }

sudhakar216 avatar Nov 18 '17 10:11 sudhakar216

Im able to create angular project by "ng new PROJECT-NAME" but while running it im getting those errors

sudhakar216 avatar Nov 18 '17 10:11 sudhakar216

I solved The Issue after 23hrs of research and continues trails

Sollution:

Add the three { "@angular/cli": "1.5.2", "@angular/compiler-cli": "^5.0.0", "typescript": "^2.4.2" } in "dependencies" too so these will be installed without error I repeat again make sure the above three are available in "dependencies" and Devdependencies too..

It will work for sure.. If you have any doubts mail me or call me

Thank you, everyone...

sudhakar216 avatar Nov 18 '17 12:11 sudhakar216

The same issue was for me too.

...
 "@angular/cli": "1.5.2",
 "@angular/compiler": "^5.0.0",
 "@angular/compiler-cli": "^5.0.0",
 "typescript": "^2.6.1"
...

Works fine in dependencies and devDep.

atereshkov avatar Nov 23 '17 22:11 atereshkov

Good to see my 23 hrs of searching is useful for people feeling good in heart thanks for posting Atereshkov

sudhakar216 avatar Nov 24 '17 18:11 sudhakar216

By default, npm install will install all modules listed as dependencies. With the --production flag, npm will not install modules listed in devDependencies. either we can go for @sudhakar216 solution of editing the package.json or

To install dev dependencies, npm --production=false install will work even with NODE_ENV=production.

Or you can run NODE_ENV=development npm install

https://github.com/npm/npm/issues/6803

lijoos avatar Nov 26 '17 09:11 lijoos

[email protected] postinstall /tmp/build_debb031ac79f5adc54e7733537e7cdf3/battalian-BlogApp-using-angular-c692bcc > ng build

   Versions of @angular/compiler-cli and typescript could not be determined.
   The most common reason for this is a broken npm install.
   
   Please make sure your package.json contains both @angular/compiler-cli and typescript in
   devDependencies, then delete node_modules and package-lock.json (if you have one) and
   run npm install again.
   npm ERR! code ELIFECYCLE
   npm ERR! errno 2
   npm ERR! [email protected] postinstall: `ng build`
   npm ERR! Exit status 2
   npm ERR!
   npm ERR! Failed at the [email protected] postinstall script.
   npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
   
   npm ERR! A complete log of this run can be found in:
   npm ERR!     /app/.npm/_logs/2017-11-28T10_40_41_273Z-debug.log

-----> Build failed

   We're sorry this build is failing! You can troubleshoot common issues here:
   https://devcenter.heroku.com/articles/troubleshooting-node-deploys
   
   If you're stuck, please submit a ticket so we can help:
   https://help.heroku.com/
   
   Love,
   Heroku

! Push rejected, failed to compile Node.js app. ! Push failed

battalian avatar Nov 28 '17 10:11 battalian