Skip to content

Instantly share code, notes, and snippets.

@nod
Created February 19, 2016 16:21
Show Gist options
  • Save nod/e660be78e7d725343157 to your computer and use it in GitHub Desktop.
Save nod/e660be78e7d725343157 to your computer and use it in GitHub Desktop.
Ionic in a directory... The easy way

local tooling for ionic

Instead of installing bower, gulp, ionic, cordova globally - I prefer to put them in the directory with the project. This way projects can have their own versions as needed.

dev

You'll create a file env.sh that lives at the root of your ionic project that you'll source when you start working to ensure everything is setup properly.

node and nvm

I also like to lock my node version using @creationix's excellent nvm.

Install nvm per the instructions.

I find that setting the nvm directory in my .bash_profile slows down bash startup so I do that here and remove it from my profile. YMMV.

Create a file in the root of your ionic directory called env.sh that looks like the following:

# initialize nvm
export NVM_DIR="${HOME}/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"  # This loads nvm

# add command here to use specific node version
nvm use 4.3.1

# add our local tools to our path
script_in_dir=path/to/project
export PATH=$PATH:$script_in_dir/node_modules/.bin

local tools

Be sure you've sourced your env with source env.sh in your shell.

Now, to get gulp, ionic, cordova, etc locked to your directory, add the following to your package.json:

  "devDependencies": {
    "bower": "^1.3.3",
    "gulp": "~3.9",
    "ionic": "~1.2",
    "cordova": "~5",
    "gulp-util": "^2.2.14",
    "shelljs": "^0.3.0"
  },

And then just install your packages.

npm install

Now your tooling is local to this directory and not global.

@jdnichollsc
Copy link

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment