I have problem to generate tabs, reported error, plz help!

I am using
global packages:

@ionic/cli-utils : 1.5.0
Ionic CLI        : 3.5.0

local packages:

@ionic/app-scripts              : 2.0.2
@ionic/cli-plugin-ionic-angular : 1.3.2
Ionic Framework                 : ionic-angular 3.5.2

System:

Node       : v6.9.5
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b 
ios-deploy : 1.9.1 
ios-sim    : 6.0.0 
npm        : 3.10.10 

And I encounter the follow problem when generate the tabs

Xis-MacBook-Pro:myIonicProject Bill$ ionic generate
? What would you like to generate: tabs
? What should the name be? mytabs
? How many tabs? 2
? Name of this tab: Tab1
? Name of this tab: Tab2
TypeError: Cannot read property 'replace' of undefined

Upgrade to the current Node LTS.,

I still have issues after I update the Node:

ionic info

global packages:

    @ionic/cli-utils : 1.5.0
    Cordova CLI      : 7.0.1 
    Ionic CLI        : 3.5.0

local packages:

    @ionic/app-scripts              : 2.0.2
    @ionic/cli-plugin-cordova       : 1.4.1
    @ionic/cli-plugin-ionic-angular : 1.3.2
    Cordova Platforms               : ios 4.4.0
    Ionic Framework                 : ionic-angular 3.5.2

System:

    Node       : v6.11.1
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b 
    ios-deploy : 1.9.1 
    ios-sim    : 6.0.0 
    npm        : 3.10.10 

The error is:

Xis-MacBook-Pro:Documents Bill$ ionic start myIonicApp
? What starter would you like to use: sidemenu
✔ Creating directory ./myIonicApp - done!
[INFO] Fetching app base (https://github.com/ionic-team/ionic2-app-base/archive/master.tar.gz)
✔ Downloading - done!
[INFO] Fetching starter template sidemenu (https://github.com/ionic-team/ionic2-starter-sidemenu/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!
> npm install --save-dev --save-exact @ionic/cli-plugin-ionic-angular@latest
✔ Running command - done!
> git init
✔ Running command - done!
> git add -A
✔ Running command - done!
> git commit -m "Initial commit" --no-gpg-sign
✔ 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
  
? Link this app to your Ionic Dashboard to use tools like Ionic View? No

Go to your newly created project: cd ./myIonicApp
Xis-MacBook-Pro:Documents Bill$ ionic generate
[ERROR] Sorry! ionic generate can only be run in an Ionic project directory.
Xis-MacBook-Pro:Documents Bill$ cd myIonicApp/
Xis-MacBook-Pro:myIonicApp Bill$ ionic generate
? What would you like to generate: tabs
? What should the name be? tab
? How many tabs? 2
? Name of this tab: T1
? Name of this tab: T2
TypeError: Cannot read property 'replace' of undefined

Xis-MacBook-Pro:myIonicApp Bill$ 

I still have issues after I update the Node:

ionic info

global packages:

@ionic/cli-utils : 1.5.0
Cordova CLI      : 7.0.1 
Ionic CLI        : 3.5.0

local packages:

@ionic/app-scripts              : 2.0.2
@ionic/cli-plugin-cordova       : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms               : ios 4.4.0
Ionic Framework                 : ionic-angular 3.5.2

System:

Node       : v6.11.1
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b 
ios-deploy : 1.9.1 
ios-sim    : 6.0.0 
npm        : 3.10.10

The error is:

Xis-MacBook-Pro:Documents Bill$ ionic start myIonicApp
? What starter would you like to use: sidemenu
:heavy_check_mark: Creating directory ./myIonicApp - done!
[INFO] Fetching app base (https://github.com/ionic-team/ionic2-app-base/archive/master.tar.gz)
:heavy_check_mark: Downloading - done!
[INFO] Fetching starter template sidemenu (https://github.com/ionic-team/ionic2-starter-sidemenu/archive/master.tar.gz)
:heavy_check_mark: Downloading - done!
:heavy_check_mark: Updating package.json with app details - done!
:heavy_check_mark: Creating configuration file ionic.config.json - done!
[INFO] Installing dependencies may take several minutes!

npm install
:heavy_check_mark: Running command - done!
npm install --save-dev --save-exact @ionic/cli-plugin-ionic-angular@latest
:heavy_check_mark: Running command - done!
git init
:heavy_check_mark: Running command - done!
git add -A
:heavy_check_mark: Running command - done!
git commit -m “Initial commit” --no-gpg-sign
:heavy_check_mark: 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

? Link this app to your Ionic Dashboard to use tools like Ionic View? No

Go to your newly created project: cd ./myIonicApp
Xis-MacBook-Pro:Documents Bill$ ionic generate
[ERROR] Sorry! ionic generate can only be run in an Ionic project directory.
Xis-MacBook-Pro:Documents Bill$ cd myIonicApp/
Xis-MacBook-Pro:myIonicApp Bill$ ionic generate
? What would you like to generate: tabs
? What should the name be? tab
? How many tabs? 2
? Name of this tab: T1
? Name of this tab: T2
TypeError: Cannot read property ‘replace’ of undefined

Xis-MacBook-Pro:myIonicApp Bill$

Install a newer npm version.

Not working.

$ brew update && brew upgrade node
Updated 3 taps (caskformula/caskformula, caskroom/cask, homebrew/core).
==> Updated Formulae
citus                     folly                     gst-plugins-bad           gst-plugins-ugly          gst-validate              kubernetes-cli            osquery                   rocksdb                   sparkey
crystal-lang              gst-editing-services      gst-plugins-base          gst-python                gstreamer                 leveldb ✔                 ppsspp                    snappy ✔                  wiredtiger
diff-so-fancy             gst-libav                 gst-plugins-good          gst-rtsp-server           influxdb@0.8              neo4j                     redis-leveldb             snzip                     x265
Error: node 8.1.4 already installed

Hi,

I have the same problem, in Windows:

$ ionic info

global packages:

@ionic/cli-utils : 1.5.0
Ionic CLI        : 3.5.0

local packages:

@ionic/app-scripts              : 2.0.2
@ionic/cli-plugin-ionic-angular : 1.3.2
Ionic Framework                 : ionic-angular 3.5.3

System:

Node       : v6.11.1
OS         : Windows 8.1
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed
npm        : 3.10.10

But, In version Ionic 2.2.1, on another computer, the statement works perfectly!!! I will try to downgrade my project.

node is not npm. node 8 usually comes with node 5.0.3 right now: https://nodejs.org/en/download/current/

You probably mean Ionic CLI 2.2.1 which is not supported any more.

4 posts were split to a new topic: Cannot ionic generate tabs: TypeError: Cannot read property ‘replace’ of undefined

@billchenxi
@cjacobm

Try this command to install the latest npm version. It worked for me :smile_cat:

npm install npm@latest -g