Ionic-framework: When I update to latest version, It didn't work by Error: Cannot find module 'reflect-metadata'

Created on 18 Dec 2016  Â·  15Comments  Â·  Source: ionic-team/ionic-framework

Ionic version: (check one with "x")
[ ] 1.x
[x] 2.x

I'm submitting a ... (check one with "x")
[x] bug report
[ ] feature request
[ ] support request => Please do not submit support requests here, use one of these channels: https://forum.ionicframework.com/ or http://ionicworldwide.herokuapp.com/

After I update ionic CLI to version 2.1.17 and create a new project by command:
ionic start projectxxx --v2 tabs

Then I try:
cd projectxxx ionic serve

Then it throw an exception:

C:\Users\Administrator\Documents\ionic\ionv2>ionic serve

> ionic-app-base@ ionic:serve C:\Users\Administrator\Documents\ionic\ionv2
> ionic-app-scripts serve
module.js:327
    throw err;
    ^

Error: Cannot find module 'reflect-metadata'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Users\Administrator\Documents\ionic\ionv2\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:1)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "ionic:serve" "--"
npm ERR! node v4.4.3
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! ionic-app-base@ ionic:serve: \`ionic-app-scripts serve\`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-app-base@ ionic:serve script 'ionic-app-scripts serve'.
npm ERR! This is most likely a problem with the ionic-app-base package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ionic-app-scripts serve
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ionic-app-base
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls ionic-app-base
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Administrator\Documents\ionic\ionv2\npm-debug.log
There was an error serving your Ionic application: There was an error with the spawned command: serve

Then I try start a project by ionic v1,It works!

So,how to fix it in ionic v2.

All 15 comments

Can you post your ionic info and the package.json
Also make sure these commands are executed properly:

npm install -g ionic@latest
npm install @ionic/app-scripts@latest

If it doesn't help try to install a new package

ionic start test --v2
cd test
ionic serve

Greetings

Still didn't work after run

npm install -g ionic@latest
npm install @ionic/app-scripts@latest

Command output:

C:\Users\Administrator\Documents\ionic\ionv2>npm install -g ionic@latest
C:\Users\Administrator\AppData\Roaming\npm\ionic -> C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic\bin\ionic
[email protected] C:\Users\Administrator\AppData\Roaming\npm\node_modules\ionic
└── @ionic/[email protected]

C:\Users\Administrator\Documents\ionic\ionv2>npm install @ionic/app-scripts@latest
npm WARN peerDependencies The peer dependency rxjs@* included from @ionic/app-scripts will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
|




npm WARN optional dep failed, continuing [email protected]
-
> [email protected] install C:\Users\Administrator\Documents\ionic\ionv2\node_modules\@ionic\app-scripts\node_modules\node-sass
> node scripts/install.js

Start downloading binary at https://github.com/sass/node-sass/releases/download/v3.10.1/win32-x64-46_binding.node
Binary downloaded and installed at C:\Users\Administrator\Documents\ionic\ionv2\node_modules\@ionic\app-scripts\node_modules\node-sass\vendor\win32-x64-46\binding.node

> [email protected] postinstall C:\Users\Administrator\Documents\ionic\ionv2\node_modules\@ionic\app-scripts\node_modules\node-sass
> node scripts/build.js

"C:\Users\Administrator\Documents\ionic\ionv2\node_modules\@ionic\app-scripts\node_modules\node-sass\vendor\win32-x64-46\binding.node" exists.
 testing binary.
Binary is fine; exiting.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "@ionic/app-scripts@latest"
npm ERR! node v4.4.3
npm ERR! npm  v2.15.1
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package [email protected] does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/[email protected] wants [email protected]

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Administrator\Documents\ionic\ionv2\npm-debug.log

C:\Users\Administrator\Documents\ionic\ionv2>ionic serve

> ionic-app-base@ ionic:serve C:\Users\Administrator\Documents\ionic\ionv2
> ionic-app-scripts serve

module.js:327
    throw err;
    ^

Error: Cannot find module 'reflect-metadata'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Users\Administrator\Documents\ionic\ionv2\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:1)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "ionic:serve" "--"
npm ERR! node v4.4.3
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! ionic-app-base@ ionic:serve: `ionic-app-scripts serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-app-base@ ionic:serve script 'ionic-app-scripts serve'.
npm ERR! This is most likely a problem with the ionic-app-base package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ionic-app-scripts serve
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ionic-app-base
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls ionic-app-base
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Administrator\Documents\ionic\ionv2\npm-debug.log
There was an error serving your Ionic application: There was an error with the spawned command: serve

C:\Users\Administrator\Documents\ionic\ionv2>ionic info

Your system information:

 ordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.4
Ionic CLI Version: 2.1.17
Ionic App Lib Version: 2.1.7
Ionic App Scripts Version: 0.0.47
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v4.4.3
Xcode version: Not installed

package.json content here:

{
  "name": "ionic-app-base",
  "author": "Ionic Framework",
  "homepage": "http://ionicframework.com/",
  "private": true,
  "scripts": {
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/storage": "1.1.6",
    "ionic-angular": "2.0.0-rc.4",
    "ionic-native": "2.2.11",
    "ionicons": "3.0.0",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "0.0.47",
    "typescript": "2.0.9"
  }
}

Try to do this command outside the ionicv2 folder and then create a new project like pointed in last post and try it again.

Oh and I see now, upgrade to node.js 6.9 you're using 4.3! - it was pointed out some way earlier you need the latest node.js

I try start a new project,but still didn't work.

command output like this

C:\Users\Administrator\Documents\ionic\ionv2>cd ../

C:\Users\Administrator\Documents\ionic>ionic start newproject --v2 tabs
Creating Ionic app in folder C:\Users\Administrator\Documents\ionic\newproject based on tabs project
Downloading: https://github.com/driftyco/ionic2-app-base/archive/master.zip
[=============================]  100%  0.0s
Downloading: https://github.com/driftyco/ionic2-starter-tabs/archive/master.zip
[=============================]  100%  0.0s
Installing npm packages...
npm WARN peerDependencies The peer dependency @angular/tsc-wrapped@* included from @ionic/app-scripts will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN peerDependencies The peer dependency rxjs@* included from @ionic/app-scripts will no
npm WARN peerDependencies longer be automatically installed to fulfill the peerDependency
npm WARN peerDependencies in npm 3+. Your application will need to depend on it explicitly.
npm WARN optional dep failed, continuing [email protected]
-
> [email protected] install C:\Users\Administrator\Documents\ionic\newproject\node_modules\@ionic\app-scripts\node_modules\node-sass
> node scripts/install.js

Start downloading binary at https://github.com/sass/node-sass/releases/download/v3.10.1/win32-x64-46_binding.node
Binary downloaded and installed at C:\Users\Administrator\Documents\ionic\newproject\node_modules\@ionic\app-scripts\node_modules\node-sass\vendor\win32-x64-46\binding.node

> [email protected] postinstall C:\Users\Administrator\Documents\ionic\newproject\node_modules\@ionic\app-scripts\node_modules\node-sass
> node scripts/build.js

"C:\Users\Administrator\Documents\ionic\newproject\node_modules\@ionic\app-scripts\node_modules\node-sass\vendor\win32-x64-46\binding.node" exists.
 testing binary.
Binary is fine; exiting.
npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! node v4.4.3
npm ERR! npm  v2.15.1
npm ERR! code EPEERINVALID

npm ERR! peerinvalid The package [email protected] does not satisfy its siblings' peerDependencies requirements!
npm ERR! peerinvalid Peer @angular/[email protected] wants [email protected]

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Administrator\Documents\ionic\newproject\npm-debug.log
Error with start undefined
Error Initializing app: There was an error with the spawned command: npminstall
There was an error with the spawned command: npminstall

C:\Users\Administrator\Documents\ionic>cd newproject

C:\Users\Administrator\Documents\ionic\newproject>ionic serve

> ionic-app-base@ ionic:serve C:\Users\Administrator\Documents\ionic\newproject
> ionic-app-scripts serve

module.js:327
    throw err;
    ^

Error: Cannot find module 'reflect-metadata'
    at Function.Module._resolveFilename (module.js:325:15)
    at Function.Module._load (module.js:276:25)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (C:\Users\Administrator\Documents\ionic\newproject\node_modules\@ionic\app-scripts\dist\aot\aot-compiler.js:4:1)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)

npm ERR! Windows_NT 10.0.14393
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "run" "ionic:serve" "--"
npm ERR! node v4.4.3
npm ERR! npm  v2.15.1
npm ERR! code ELIFECYCLE
npm ERR! ionic-app-base@ ionic:serve: `ionic-app-scripts serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ionic-app-base@ ionic:serve script 'ionic-app-scripts serve'.
npm ERR! This is most likely a problem with the ionic-app-base package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ionic-app-scripts serve
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs ionic-app-base
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!
npm ERR!     npm owner ls ionic-app-base
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     C:\Users\Administrator\Documents\ionic\newproject\npm-debug.log
There was an error serving your Ionic application: There was an error with the spawned command: serve

After I update my node to version 6.9.1

It Worked

Thank You graphefruit

OS
Ubuntu 16.04

Install reflect-metadata and angular-cli
sudo npm install -g reflect-metadata
sudo npm install -g angular-cli
ionic serve

use nodejs 4.8.0 , si tiene problema con version de nodejs, usa NVM

try "npm update" in your app folder

@dovewi totally is right, this is node version problem. but point need to highlight still, if you have updated the node version , and try to run serve cmd on old project create by node V4 then its not going to work.

so create new one, and try

Docs are a bit out of date:

To install the CLI, you will need to first install node and npm. Note: The CLI requires Node 4.X (Node 5.X has been known to cause a number of issues). —https://ionicframework.com/docs/cli/

Open your project folder
Open Package.json and add

"reflect-metadata": "^0.1.3",

run

npm install

on the folder --> ionic is no longer adding reflect-metadata to the package.json

cd into your project folder
Type npm install reflect-metadata

Now run ionic serve

OS

Ubuntu 16.04

Updating node from 4 to 6 works for me:

sudo apt remove --purge nodejs

If you are not sure about --purge don't use it:

sudo apt remove nodejs

Install nodejs 6

Default commands:

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

into your project folder
run in terminal npm install reflect-metadata
then run ionic serve

;)

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

brandyscarney picture brandyscarney  Â·  3Comments

daveshirman picture daveshirman  Â·  3Comments

SebastianGiro picture SebastianGiro  Â·  3Comments

manucorporat picture manucorporat  Â·  3Comments

brandyscarney picture brandyscarney  Â·  3Comments