Ionic serve error: cannot find module ‘typescript’ on Windows


#1

Can someone help me, please, with this error? I’m a beginner user and dont know what to do with this.
image

Thanks!


#2

Have you tried typing:

npm install -g typescript

to install typescript?


#3

Hi rtpHarry,

Thank you for answer, but…

I’ve installed typescript, but it is not found:

As you said:

but…
image

Do you know what more can I do?


#4

Post your ionic info output please.


#5

Here it is:

It look that are something wrong… what should I do to fix it?

Thanks very much.


#6

Delete node_modules, run npm install, look at the output if there are errors. If so, post them. (But please as text, not as screenshots)


#7

Thank you for your answer and I realy sorry by my ignorance. I tried the command npm delete app-scripts but the command was not known. Tried apm delete app-scripts but the answer was:

Uninstalling app-scripts failed
Failed to delete app-scripts: Does not exist

I realy dont know how to uninstall it.

On trying to install app-scripts (npm install -g app-scripts) the answer was:

C:\Users\cleon\AppData\Roaming\npm
`-- app-scripts@0.0.0

ionic info

[ERROR] Error with .\node_modules@ionic\app-scripts\package.json file: FILE_NOT_FOUND

cli packages:

@ionic/cli-plugin-ionic-angular : 1.4.0 (C:\Users\cleon\documents\aplicativos\app001p\node_modules\@ionic\cli-plugin-ionic-angular)
@ionic/cli-utils                : 1.6.0 (C:\Users\cleon\documents\aplicativos\app001p\node_modules\@ionic\cli-utils)
ionic (Ionic CLI)               : 3.6.0 (C:\Users\cleon\documents\aplicativos\app001p\node_modules\ionic)

local packages:

@ionic/app-scripts : not installed
Ionic Framework    : ionic-angular 3.6.0

System:

Node : v6.11.1
OS   : Windows 10
npm  : 3.10.10

#8

Drag node_modules into the recycle bin.


#9

Nobody said you should uninstall app-scripts. It’s called @ionic/app-scripts and not installed for you in the first place - that is the problem.

Delete the node_modules folder in you Ionic project by right-clicking on it and selecting “Delete”. Then do the rest of the things I posted.


#10

Thank you. I did as you said now:

PS C:\Users\cleon\Documents\APLICATIVOS\App001p> npm install
App001p@0.0.1 C:\Users\cleon\Documents\APLICATIVOS\App001p
±- @angular/common@4.1.3
±- @angular/compiler@4.1.3
±- @angular/compiler-cli@4.1.3
| ±- @angular/tsc-wrapped@4.1.3
| | ±- tsickle@0.21.6
| | | ±- mkdirp@0.5.1
| | | | -- minimist@0.0.8 | | | +-- source-map@0.5.6 | | |– source-map-support@0.4.15
| | -- UNMET PEER DEPENDENCY typescript@^2.1.0 | +-- minimist@1.2.0 | +-- reflect-metadata@0.1.10 |– UNMET PEER DEPENDENCY typescript@^2.1.5
±- @angular/core@4.1.3
±- @angular/forms@4.1.3
±- @angular/http@4.1.3
±- @angular/platform-browser@4.1.3
±- @angular/platform-browser-dynamic@4.1.3
±- @ionic-native/core@3.12.1
±- @ionic-native/splash-screen@3.12.1
±- @ionic-native/status-bar@3.12.1
±- @ionic/storage@2.0.1
| ±- @types/localforage@0.0.30
| ±- localforage@1.4.3
| | -- lie@3.0.2 | | +-- es3ify@0.1.4 | | | +-- esprima-fb@3001.1.0-dev-harmony-fb | | | +-- jstransform@3.0.0 | | | | +-- base62@0.1.1 | | | |– source-map@0.1.31
| | | | -- amdefine@1.0.1 | | |– through@2.3.8
| | ±- immediate@3.0.6
| | ±- inline-process-browser@1.0.0
| | | ±- falafel@1.2.0
| | | | ±- acorn@1.2.2
| | | | ±- foreach@2.0.5
| | | | -- object-keys@1.0.11 | | |– through2@0.6.5
| | | ±- readable-stream@1.0.34
| | | | ±- core-util-is@1.0.2
| | | | ±- inherits@2.0.3
| | | | -- string_decoder@0.10.31 | | |– xtend@4.0.1
| | -- unreachable-branch-transform@0.3.0 | | +-- esmangle-evaluator@1.0.1 | |– recast@0.10.43
| | ±- ast-types@0.8.15
| | ±- esprima-fb@15001.1001.0-dev-harmony-fb
| | -- private@0.1.7 |– localforage-cordovasqlitedriver@1.5.0
±- ionic-angular@3.6.0
±- ionicons@3.0.0
±- rxjs@5.4.0
| -- symbol-observable@1.0.4 +-- sw-toolbox@3.6.0 | +-- path-to-regexp@1.7.0 | |– isarray@0.0.1
| -- serviceworker-cache-polyfill@4.0.0– zone.js@0.8.12

npm WARN @angular/compiler-cli@4.1.3 requires a peer of typescript@^2.0.2 but none was installed.
npm WARN @angular/tsc-wrapped@4.1.3 requires a peer of typescript@^2.1.5 but none was installed.
npm WARN tsickle@0.21.6 requires a peer of typescript@^2.1.0 but none was installed.

After run ionic info the results are:

[ERROR] Error with .\node_modules@ionic\app-scripts\package.json file: FILE_NOT_FOUND

cli packages: (C:\Users\cleon\Documents\APLICATIVOS\App001p\node_modules)

@ionic/cli-plugin-ionic-angular : 1.4.1
@ionic/cli-utils                : 1.7.0
ionic (Ionic CLI)               : 3.7.0

local packages:

@ionic/app-scripts : not installed
Ionic Framework    : ionic-angular 3.6.0

System:

Node : v6.11.1
OS   : Windows 10
npm  : 3.10.10

#11

Post your package.json please.
Run ionic start blank blank and compare that package.json with yours.


#12

I was not sure what “post your package.json” means, so I opened it with notes. I hope was it…

App001p:

{
  "name": "App001p",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@ionic-native/core": "3.12.1",
    "@ionic-native/splash-screen": "3.12.1",
    "@ionic-native/status-bar": "3.12.1",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.6.0",
    "ionicons": "3.0.0",
    "rxjs": "5.4.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@ionic/app-scripts": "2.1.3",
    "@ionic/cli-plugin-ionic-angular": "1.4.1",
    "ionic": "3.7.0",
    "typescript": "2.3.4"
  },
  "description": "An Ionic project"
}

BLANK

{
  "name": "blank",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "4.1.3",
    "@angular/compiler": "4.1.3",
    "@angular/compiler-cli": "4.1.3",
    "@angular/core": "4.1.3",
    "@angular/forms": "4.1.3",
    "@angular/http": "4.1.3",
    "@angular/platform-browser": "4.1.3",
    "@angular/platform-browser-dynamic": "4.1.3",
    "@ionic-native/core": "3.12.1",
    "@ionic-native/splash-screen": "3.12.1",
    "@ionic-native/status-bar": "3.12.1",
    "@ionic/storage": "2.0.1",
    "ionic-angular": "3.6.0",
    "ionicons": "3.0.0",
    "rxjs": "5.4.0",
    "sw-toolbox": "3.6.0",
    "zone.js": "0.8.12"
  },
  "devDependencies": {
    "@ionic/app-scripts": "2.1.3",
    "@ionic/cli-plugin-ionic-angular": "1.4.1",
    "ionic": "3.7.0",
    "typescript": "2.3.4"
  },
  "description": "An Ionic project"
}

Running ionic serve at the new blank app, the result is the same: Error: Cannot find module ‘typescript’


#13

Your devDependencies are not being installed…

Can you run ionic start blank2 blank --verbose please and post the output here?

Also in your original project, run npm install @ionic/app-scripts @ionic/cli-plugin-ionic-angular ionic typescript and see if this fixes things. Try to run ionic info after doing this. (THis is not the solution, just a workaround to try finding out what is wrong)


#14

Great, Sujan12, it worked!

here are the results of running ionic start blank2 blank --verbose:

PS C:\Users\cleon\Documents\APLICATIVOS> ionic start blank2 blank --verbose
[DEBUG] CLI flags: { interactive: true, confirm: false }
[DEBUG] { cwd: 'C:\\Users\\cleon\\Documents\\APLICATIVOS', local: false, binPath:
        'C:\\Users\\cleon\\AppData\\Roaming\\npm\\node_modules\\ionic\\bin\\ionic', libPath:
        'C:\\Users\\cleon\\AppData\\Roaming\\npm\\node_modules\\ionic\\dist\\index.js' }
[DEBUG] Loading global plugin @ionic/cli-plugin-proxy
[DEBUG] Throwing PLUGIN_NOT_INSTALLED for global @ionic/cli-plugin-proxy
[DEBUG] globalDeps=
[WARN] Git CLI not found on your PATH. You may wish to install it to version control your app.
       See installation docs for git: https://git-scm.com/book/en/v2/Getting-Started-Installing-Git

       Use --no-git to disable this warning.

√ Creating directory .\blank2 - done!
[INFO] Fetching app base (https://github.com/ionic-team/ionic2-app-base/archive/master.tar.gz)
√ Downloading - done!
[INFO] Fetching starter template blank (https://github.com/ionic-team/ionic2-starter-blank/archive/master.tar.gz)
√ Downloading - done!
√ Updating package.json with app details - done!
√ Creating configuration file ionic.config.json - done!
[INFO] Installing dependencies may take several minutes!
> npm install

Running command - done!
[DEBUG] localDeps=ionic,@ionic/cli-plugin-ionic-angular
> npm install --save-dev --save-exact ionic@latest
√ Running command - done!
> npm install --save-dev --save-exact @ionic/cli-plugin-ionic-angular@latest
√ Running command - done!
> npm dedupe
√ Running command - done!

♬♫♬♫ Your Ionic app is ready to go! ♬♫♬♫

Run your app in the browser (great for initial development):
  ionic serve

Run on a device or simulator:
ionic cordova run ios

Test and share your app on a device with the Ionic View app:
  http://view.ionic.io


Next Steps:
Go to your newly created project: cd .\blank2

And the results of ionic info:

PS C:\Users\cleon\Documents\APLICATIVOS\App001p> ionic info

cli packages: (C:\Users\cleon\Documents\APLICATIVOS\App001p\node_modules)

    @ionic/cli-plugin-ionic-angular : 1.4.1
    @ionic/cli-utils                : 1.7.0
    ionic (Ionic CLI)               : 3.7.0

local packages:

    @ionic/app-scripts : 2.1.3
    Ionic Framework    : ionic-angular 3.6.0

System:

    Node : v6.11.1
    OS   : Windows 10
    npm  : 3.10.10

Thank you for your help and your patience.


#15

Hey guys,
Having a similar issue though the above didn’t work.

This is the error I’m getting:

Blockquote
Error: Cannot find module 'typescript’
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object. (C:\Users\kierandes\Documents\DSF\Apps\CSA\main\node_modules@ionic\app-scripts\dist\transpile.js:42:10)
at Module._compile (module.js:570:32)
at Object.Module._extensions…js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)

Thanks in advance,
Kieran


#16

I got exactly the same error. Have you found any solution yet? I did run $ ionic start blank2 blank --verbose
in a folder above my project, but it didn’t work