NativeScript / nativescript-schematics

nativescript, mobile, schematics, angular
Apache License 2.0
185 stars 26 forks source link

Cannot find module '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript' #274

Open propelsoftware opened 4 years ago

propelsoftware commented 4 years ago

Environment { "name": "propel-web-client", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "^8.0.0-beta.11", "@angular/cdk": "^7.2.1", "@angular/common": "^8.0.0-beta.11", "@angular/compiler": "^8.0.0-beta.11", "@angular/core": "^8.0.0-beta.11", "@angular/forms": "^8.0.0-beta.11", "@angular/http": "^6.1.0", "@angular/material": "^7.2.1", "@angular/platform-browser": "^8.0.0-beta.11", "@angular/platform-browser-dynamic": "^8.0.0-beta.11", "@angular/router": "^8.0.0-beta.11", "@vaadin/vaadin-button": "^2.1.2", "@vaadin/vaadin-grid": "^5.2.7", "@vaadin/vaadin-text-field": "^2.1.7", "amexio-chart-d3": "0.0.9", "amexio-ng-extensions": "^5.20.3", "angular-font-awesome": "^3.1.2", "core-js": "^2.5.4", "d3": "^5.7.0", "font-awesome": "^4.7.0", "hammerjs": "^2.0.8", "ngx-device-detector": "^1.3.20", "rxjs": "~6.4.0", "zone.js": "~0.9.0" }, "devDependencies": { "@angular-devkit/build-angular": "^0.13.9", "@angular/cli": "^7.3.9", "@angular/compiler-cli": "^8.0.0-beta.11", "@angular/language-service": "^8.0.0-beta.11", "@nativescript/schematics": "^1.0.0", "@types/jasmine": "~2.8.8", "@types/jasminewd2": "~2.0.3", "@types/node": "~8.9.4", "codelyzer": "~4.3.0", "jasmine-core": "~2.99.1", "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": "~1.1.2", "karma-jasmine-html-reporter": "^0.2.2", "node-sass": "^4.12.0", "protractor": "~5.4.0", "sass-loader": "^7.1.0", "ts-node": "~7.0.0", "tslint": "~5.11.0", "typescript": "~3.3.4000" } }

Describe the bug I already have an angular project. trying to migrate it to add nativescript to make it as shared project. I followed the steps mentioned in https://docs.nativescript.org/angular/code-sharing/migrating-a-web-project.

I executed npm install -g --unsafe-perm nativescript to install CLI, it was sucessful.

When i run ng add @nativescript/schematics , it throw the below error. so it doesnt create any nativescript specific files in my project, like main.tns.ts

ng add @nativescript/schematics --sample Your global Angular CLI version (8.3.5) is greater than your local version (7.3.9). The local Angular CLI version is used.

To disable this warning use "ng config -g cli.warnings.versionMismatch false". Skipping installation: Package already installed **Cannot find module '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript' Require stack:

Expected behavior

Sample project

Additional context

AmbitiousAnil commented 4 years ago

Firstly You need to Install nativescript-schematics as dev dependency. So run this command:

npm i --save-dev @nativescript/schematics.

Since this installs latest nativescript-schematics you need to install latest @angular/cli. So run this command: npm install -D @angular/cli

This Should Solve the Problem

linocatucci commented 4 years ago

Hello @AmbitiousAnil, I have tried your solution but I still get : Cannot find module '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript'

I have installed Angular 9 and try to install Angular Material Any other ideas?

rbudnar commented 4 years ago

I am having the same issue when running ng g c .... I recently upgraded from @nativescript/schematics 0.4.0 to 1.0.0 and started getting this error. Rolling back to 0.4.0 fixed the issue for me and I can run ng g c again (I tried rolling back to 0.7.3 but that didn't work). Not a great solution of course but its at least working.

For reference:

[error] Error: Cannot find module '@schematics/angular/third_party/github.com/Microsoft/TypeScript/lib/typescript'
Require stack:
- H:\...\node_modules\@nativescript\schematics\src\angular-project-parser.js
- H:\...\node_modules\@nativescript\schematics\src\generate\component\index.js
- H:\...\node_modules\@angular-devkit\schematics\tools\export-ref.js
- H:\...\node_modules\@angular-devkit\schematics\tools\index.js
- H:\...\node_modules\@angular\cli\utilities\json-schema.js
- H:\...\node_modules\@angular\cli\models\command-runner.js
- H:\...\node_modules\@angular\cli\lib\cli\index.js
- C:\Users\---\AppData\Local\Yarn\Data\global\node_modules\@angular\cli\lib\init.js
- C:\Users\---\AppData\Local\Yarn\Data\global\node_modules\@angular\cli\bin\ng
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:793:17)
    at Function.Module._load (internal/modules/cjs/loader.js:686:27)
    at Module.require (internal/modules/cjs/loader.js:848:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (H:\...\node_modules\@nativescript\schematics\src\angular-project-parser.js:3:12)
    at Module._compile (internal/modules/cjs/loader.js:955:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:991:10)
    at Module.load (internal/modules/cjs/loader.js:811:32)
    at Function.Module._load (internal/modules/cjs/loader.js:723:14)
    at Module.require (internal/modules/cjs/loader.js:848:19)
olastor commented 4 years ago

Had the same problem when running ng add @nativescript/schematics, but after running yarn add -D @angular/cli it worked.

kjmj commented 4 years ago

Had the same problem when running ng add @nativescript/schematics, but after running yarn add -D @angular/cli it worked.

This fixed it for me as well.