Error while creating project and adding platform

Hi Team,

I am creating ionic 2 cordova project i am getting below error, directory is getting created but gives error while adding dependencies and also getting error while adding platform.

D:>cd Work

D:\Work>cd Android

D:\Work\Android>cd GreatConversations

D:\Work\Android\GreatConversations>ionic cordova platform add

? What platform would you like to add ios, android:
D:\Work\Android\GreatConversations>ionic cordova platform add android

cordova platform add android --save
× Running command - failed!
[ERROR] Exception: Using cordova-fetch for cordova-android@~6.2.2

    Error: Failed to fetch platform cordova-android@~6.2.2
    Probably this is either a connection problem, or platform spec is incorrect.
    Check your connection and platform name/version/URL.
    Error: cmd: Command failed with exit code 4294963248 Error output:
    npm ERR! path D:\Work\Android\GreatConversations\node_modules\.staging
    npm ERR! code EPERM
    npm ERR! errno -4048
    npm ERR! syscall unlink
    npm ERR! Error: EPERM: operation not permitted, unlink
    'D:\Work\Android\GreatConversations\node_modules\.staging'
    npm ERR!  { Error: EPERM: operation not permitted, unlink
    'D:\Work\Android\GreatConversations\node_modules\.staging'
    npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink
    \'D:\\Work\\Android\\GreatConversations\\node_modules\\.staging\'',
    npm ERR!   errno: -4048,
    npm ERR!   code: 'EPERM',
    npm ERR!   syscall: 'unlink',
    npm ERR!   path: 'D:\\Work\\Android\\GreatConversations\\node_modules\\.staging' }
    npm ERR!
    npm ERR! Please try running this command again as root/Administrator.

    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\kundansakpal\AppData\Roaming\npm-cache\_logs\2017-08-30T16_07_11_338Z-debug.log

D:\Work\Android\GreatConversations>ionic remove greatconversations
[ERROR] Unable to find command: remove greatconversations

_ _
() ()


| |/ _ | '_ | |/ |
| | (_) | | | | | (

||___/|| |||___| CLI 3.9.2

Usage:

$ ionic <command> [<args>] [--help] [--verbose] [--quiet] [--no-interactive] [--confirm] [options]

Global Commands:

config <subcommand> ...... Manage CLI and project config values (subcommands: get, set)
docs ..................... Open the Ionic documentation website
info ..................... Print system/environment info
login .................... Login with your Ionic ID
signup ................... Create an Ionic account
start .................... Create a new project
telemetry ................ Opt in and out of telemetry

Project Commands:

build .................... Build web assets and prepare your app for any platform targets
cordova <subcommand> ..... Cordova functionality (subcommands: build, compile, emulate, platform, plugin, prepare,
                           resources, run)
generate ................. Generate pipes, components, pages, directives, providers, and tabs (ionic-angular >=
                           3.0.0) (alias: g)
link ..................... Connect your local app to Ionic
package <subcommand> ..... Commands for Ionic Package (subcommands: build, download, info, list)
serve .................... Start a local dev server for app dev/testing
upload ................... Upload a new snapshot of your app

D:\Work\Android\GreatConversations>cd…

D:\Work\Android>ionic remove GreatConversations
[ERROR] Unable to find command: remove GreatConversations

    You may need to be in an Ionic project directory.

_ _
() ()


| |/ _ | '_ | |/ |
| | (_) | | | | | (

||___/|| |||___| CLI 3.9.2

Usage:

$ ionic <command> [<args>] [--help] [--verbose] [--quiet] [--no-interactive] [--confirm] [options]

Global Commands:

config <subcommand> ...... Manage CLI and project config values (subcommands: get, set)
docs ..................... Open the Ionic documentation website
info ..................... Print system/environment info
login .................... Login with your Ionic ID
signup ................... Create an Ionic account
start .................... Create a new project
telemetry ................ Opt in and out of telemetry

Project Commands:

You are not in a project directory.

D:\Work\Android>ionic start MyIonicGC super
[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 .\MyIonicGC - done!
[INFO] Fetching app base (https://github.com/ionic-team/ionic2-app-base/archive/master.tar.gz)
√ Downloading - done!
[INFO] Fetching starter template super (https://github.com/ionic-team/ionic-starter-super/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 - failed!
[ERROR] An error occurred while running npm install (exit code 1):

    npm WARN deprecated babili@0.1.2: babili has been renamed to babel-minify. Please update to babel-minify
    npm WARN deprecated babel-preset-babili@0.1.4: babili has been renamed to babel-minify. Please update to
    babel-preset-minify
    npm WARN deprecated object-keys@0.2.0: Please update to the latest object-keys
    npm WARN ajv-keywords@2.1.0 requires a peer of ajv@>=5.0.0 but none was installed.
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: autoprefixer@7.1.1 (node_modules\autoprefixer):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\autoprefixer-e25f364a\AUTHORS'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: hash.js@1.1.3 (node_modules\hash.js):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open
    'D:\Work\Android\MyIonicGC\node_modules\.staging\hash.js-5a1fbe33\package.json'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: resolve@1.4.0 (node_modules\resolve):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open
    'D:\Work\Android\MyIonicGC\node_modules\.staging\resolve-d9746415\index.js'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass@4.5.3 (node_modules\node-sass):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, open
    'D:\Work\Android\MyIonicGC\node_modules\.staging\node-sass-eb6bbb40\CHANGELOG.md'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: loose-envify@1.3.1 (node_modules\loose-envify):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\loose-envify-568ed2d1\README.md'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: asn1.js@4.9.1 (node_modules\asn1.js):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\asn1.js-8c2179f8\README.md'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: babel-runtime@6.26.0 (node_modules\babel-runtime):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\babel-runtime-e1f81aa1\core-js.js'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: babel-preset-babili@0.1.4 (node_modules\babel-preset-babili):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\babel-preset-babili-7de08827\README.md'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: invariant@2.2.2 (node_modules\invariant):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\invariant-4848196f\browser.js'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: des.js@1.0.0 (node_modules\des.js):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\des.js-6facb415\README.md'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: elliptic@6.4.0 (node_modules\elliptic):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\elliptic-aab61678\README.md'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: webpack@3.5.5 (node_modules\webpack):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\webpack-9c260f4b\README.md'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: pako@0.2.9 (node_modules\pako):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\pako-15459c11\README.md'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: nan@2.7.0 (node_modules\nan):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\nan-2420ca23\README.md'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: lodash.some@4.6.0 (node_modules\lodash.some):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\lodash.some-16a650b3\index.js'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\fsevents):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\fsevents-77746fb4\install.js'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: mkdirp@0.5.1 (node_modules\mkdirp):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\mkdirp-771806de\bin\cmd.js'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: tslint@5.7.0 (node_modules\tslint):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\tslint-5e775f81\README.md'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: lodash@4.17.4 (node_modules\lodash):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\lodash-1f481b39\_baseToString.js'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: babel-plugin-minify-dead-code-elimination@0.1.7
    (node_modules\babel-plugin-minify-dead-code-elimination):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\babel-plugin-minify-dead-code-elimination-b8d08102\lib\index.js'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: async@2.5.0 (node_modules\async):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\async-c16d2b95\forever.js'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: livereload-js@2.2.2 (node_modules\livereload-js):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\livereload-js-0b2b5bf5\dist\livereload.js'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: reflect-metadata@0.1.10 (node_modules\reflect-metadata):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\reflect-metadata-d0fb5f60\Reflect.js'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: loader-utils@1.1.0 (node_modules\loader-utils):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\loader-utils-edeca8c4\CHANGELOG.md'
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: escope@3.6.0 (node_modules\escope):
    npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, utime
    'D:\Work\Android\MyIonicGC\node_modules\.staging\escope-ecf496e5\lib\definition.js'

    npm ERR! code EINTEGRITY
    npm ERR! sha512-BEMB+WhtpTZCnBA6t+TMtfZaukcqNS5zlTAV53s+U92p+6Hg6BLVzmOvxqm0tA/TSfwXNFtQ08lxS8uMFUxivA==
    integrity checksum failed when using sha512: wanted
    sha512-BEMB+WhtpTZCnBA6t+TMtfZaukcqNS5zlTAV53s+U92p+6Hg6BLVzmOvxqm0tA/TSfwXNFtQ08lxS8uMFUxivA== but got
    sha512-2NxYJEh3wMSsPvkVdfa/2YGWEaqaymqAbxrB8CSwzBtKdi06LVTNRyczVnxlyG60MFwSyNaIVLxzl01WCm1AQw==. (262144 bytes)

    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\kundansakpal\AppData\Roaming\npm-cache\_logs\2017-08-30T16_12_56_821Z-debug.log

D:\Work\Android>cd MyIonicGC

D:\Work\Android\MyIonicGC>ionic platform add android
The platform command has been renamed. To find out more, run:

ionic cordova platform --help

D:\Work\Android\MyIonicGC>ionic cordova platform add android
[INFO] Enabling Cordova integration.

ionic config set integrations.cordova {} --json --force
[OK] integrations.cordova set to {} in .\ionic.config.json!
cordova platform add android --save
× Running command - failed!
[ERROR] Exception: Using cordova-fetch for cordova-android@~6.2.2

    Error: Failed to fetch platform cordova-android@~6.2.2
    Probably this is either a connection problem, or platform spec is incorrect.
    Check your connection and platform name/version/URL.
    Error: cmd: Command failed with exit code 4294963248 Error output:
    npm ERR! path D:\Work\Android\MyIonicGC\node_modules\.staging\cordova-android-9cecc699
    npm ERR! code EPERM
    npm ERR! errno -4048
    npm ERR! syscall unlink
    npm ERR! Error: EPERM: operation not permitted, unlink
    'D:\Work\Android\MyIonicGC\node_modules\.staging\cordova-android-9cecc699'
    npm ERR!  { Error: EPERM: operation not permitted, unlink
    'D:\Work\Android\MyIonicGC\node_modules\.staging\cordova-android-9cecc699'
    npm ERR!   cause:
    npm ERR!    { Error: EPERM: operation not permitted, unlink
    'D:\Work\Android\MyIonicGC\node_modules\.staging\cordova-android-9cecc699'
    npm ERR!      type: 'OperationalError',
    npm ERR!      '$error': '$error',
    npm ERR!      cause:
    npm ERR!       { errno: -4048,
    npm ERR!         code: 'EPERM',
    npm ERR!         syscall: 'unlink',
    npm ERR!         path: 'D:\\Work\\Android\\MyIonicGC\\node_modules\\.staging\\cordova-android-9cecc699' },
    npm ERR!      isOperational: true,
    npm ERR!      errno: -4048,
    npm ERR!      code: 'EPERM',
    npm ERR!      syscall: 'unlink',
    npm ERR!      path: 'D:\\Work\\Android\\MyIonicGC\\node_modules\\.staging\\cordova-android-9cecc699' },
    npm ERR!   stack: 'Error: EPERM: operation not permitted, unlink
    \'D:\\Work\\Android\\MyIonicGC\\node_modules\\.staging\\cordova-android-9cecc699\'',
    npm ERR!   type: 'OperationalError',
    npm ERR!   '$error': '$error',
    npm ERR!   errno: -4048,
    npm ERR!   code: 'EPERM',
    npm ERR!   syscall: 'unlink',
    npm ERR!   path: 'D:\\Work\\Android\\MyIonicGC\\node_modules\\.staging\\cordova-android-9cecc699',
    npm ERR!   parent: 'MyIonicGC' }
    npm ERR!
    npm ERR! Please try running this command again as root/Administrator.

    npm ERR! A complete log of this run can be found in:
    npm ERR!     C:\Users\kundansakpal\AppData\Roaming\npm-cache\_logs\2017-08-30T16_14_33_276Z-debug.log

D:\Work\Android\MyIonicGC>

Your problem is probably with npm, something to do with permissions and files. This happens quite often and is almost impossible to successfully debug (at least here in the forum).

One solution: Uninstall your node, install nvm (or nvm-windows when you are using Windows), install a new node with this, then install ionic and cordova again and try your command again. The problem should be gone.

1 Like