Ionic start failing - unable to start new project


#1

sudo ionic start live-run2 tabs

:heavy_check_mark: Creating directory ./live-run2 - done!
:heavy_check_mark: Downloading and extracting tabs starter - done!

? Would you like to integrate your new app with Cordova to target native iOS and
Android? Yes
:heavy_check_mark: Personalizing ionic.config.json and package.json - done!

ionic integrations enable cordova --quiet
:heavy_check_mark: Downloading integration cordova - done!
:heavy_check_mark: Copying integrations files to project - done!
[OK] Added cordova integration!

Installing dependencies may take several minutes.

:sparkles: IONIC DEVAPP :sparkles:

Speed up development with the Ionic DevApp, our fast, on-device testing mobile app

  • :key: Test on iOS and Android without Native SDKs
  • :rocket: LiveReload for instant style and JS updates

️–> Install DevApp: https://bit.ly/ionic-dev-app <–

npm i
Running command

[ERROR] An error occurred while running npm i (exit code 1):

    > fsevents@1.1.3 install
    /Working/ionicV2/live-run2/node_modules/fsevents
    > node install

    [fsevents] Success:
    "/Working/ionicV2/live-run2/node_modules/fsevents/lib/binding/Release/node-v57-darwin-x64/fse.node"
    already installed
    Pass --update-binary to reinstall or --build-from-source to recompile

    > node-sass@4.7.2 install
    /Working/ionicV2/live-run2/node_modules/node-sass
    > node scripts/install.js

    Unable to save binary
    /Working/ionicV2/live-run2/node_modules/node-sass/vendor/darwin-x64-57 :
    { Error: EACCES: permission denied, mkdir
    '/Working/ionicV2/live-run2/node_modules/node-sass/vendor'
         at Object.fs.mkdirSync (fs.js:885:18)
         at sync
    (/Working/ionicV2/live-run2/node_modules/mkdirp/index.js:71:13)
         at Function.sync
    (/Working/ionicV2/live-run2/node_modules/mkdirp/index.js:77:24)
         at checkAndDownloadBinary
    (/Working/ionicV2/live-run2/node_modules/node-sass/scripts/install.js:111:11)
         at Object.<anonymous>
    (/Working/ionicV2/live-run2/node_modules/node-sass/scripts/install.js:154:1)
         at Module._compile (module.js:652:30)
         at Object.Module._extensions..js (module.js:663:10)
         at Module.load (module.js:565:32)
         at tryModuleLoad (module.js:505:12)
         at Function.Module._load (module.js:497:3)
       errno: -13,
       code: 'EACCES',
       syscall: 'mkdir',
       path: '/Working/ionicV2/live-run2/node_modules/node-sass/vendor' }

    > uglifyjs-webpack-plugin@0.4.6 postinstall
    /Working/ionicV2/live-run2/node_modules/uglifyjs-webpack-plugin
    > node lib/post_install.js


    > node-sass@4.7.2 postinstall
    /Working/ionicV2/live-run2/node_modules/node-sass
    > node scripts/build.js

    Building: /usr/local/bin/node
    /Working/ionicV2/live-run2/node_modules/node-gyp/bin/node-gyp.js rebuild
    --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags=
    --libsass_library=
    gyp info it worked if it ends with ok
    gyp verb cli [ '/usr/local/bin/node',
    gyp verb cli
    '/Working/ionicV2/live-run2/node_modules/node-gyp/bin/node-gyp.js',
    gyp verb cli   'rebuild',
    gyp verb cli   '--verbose',
    gyp verb cli   '--libsass_ext=',
    gyp verb cli   '--libsass_cflags=',
    gyp verb cli   '--libsass_ldflags=',
    gyp verb cli   '--libsass_library=' ]
    gyp info using node-gyp@3.6.2
    gyp info using node@8.11.1 | darwin | x64
    gyp verb command rebuild []
    gyp verb command clean []
    gyp verb clean removing "build" directory
    gyp verb command configure []
    gyp verb check python checking for Python executable "python2" in the
    PATH
    gyp verb `which` failed Error: not found: python2
    gyp verb `which` failed     at getNotFoundError
    (/Working/ionicV2/live-run2/node_modules/which/which.js:13:12)
    gyp verb `which` failed     at F
    (/Working/ionicV2/live-run2/node_modules/which/which.js:68:19)
    gyp verb `which` failed     at E
    (/Working/ionicV2/live-run2/node_modules/which/which.js:80:29)
    gyp verb `which` failed     at
    /Working/ionicV2/live-run2/node_modules/which/which.js:89:16
    gyp verb `which` failed     at
    /Working/ionicV2/live-run2/node_modules/isexe/index.js:42:5
    gyp verb `which` failed     at
    /Working/ionicV2/live-run2/node_modules/isexe/mode.js:8:5
    gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
    gyp verb `which` failed  python2 { Error: not found: python2
    gyp verb `which` failed     at getNotFoundError
    (/Working/ionicV2/live-run2/node_modules/which/which.js:13:12)
    gyp verb `which` failed     at F
    (/Working/ionicV2/live-run2/node_modules/which/which.js:68:19)
    gyp verb `which` failed     at E
    (/Working/ionicV2/live-run2/node_modules/which/which.js:80:29)
    gyp verb `which` failed     at
    /Working/ionicV2/live-run2/node_modules/which/which.js:89:16
    gyp verb `which` failed     at
    /Working/ionicV2/live-run2/node_modules/isexe/index.js:42:5
    gyp verb `which` failed     at
    /Working/ionicV2/live-run2/node_modules/isexe/mode.js:8:5
    gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:152:21)
    gyp verb `which` failed   stack: 'Error: not found: python2\n    at
    getNotFoundError
    (/Working/ionicV2/live-run2/node_modules/which/which.js:13:12)\n    at F
    (/Working/ionicV2/live-run2/node_modules/which/which.js:68:19)\n    at E
    (/Working/ionicV2/live-run2/node_modules/which/which.js:80:29)\n    at
    /Working/ionicV2/live-run2/node_modules/which/which.js:89:16\n    at
    /Working/ionicV2/live-run2/node_modules/isexe/index.js:42:5\n    at
    /Working/ionicV2/live-run2/node_modules/isexe/mode.js:8:5\n    at
    FSReqWrap.oncomplete (fs.js:152:21)',
    gyp verb `which` failed   code: 'ENOENT' }
    gyp verb check python checking for Python executable "python" in the
    PATH
    gyp verb `which` succeeded python /usr/bin/python
    gyp verb check python version `/usr/bin/python -c "import platform;
    print(platform.python_version());"` returned: "2.7.10\n"
    gyp verb get node dir no --target version specified, falling back to
    host node version: 8.11.1
    gyp verb command install [ '8.11.1' ]
    gyp verb install input version string "8.11.1"
    gyp verb install installing version: 8.11.1
    gyp verb install --ensure was passed, so won't reinstall if already
    installed
    gyp verb install version is already installed, need to check
    "installVersion"
    gyp verb got "installVersion" 9
    gyp verb needs "installVersion" 9
    gyp verb install version is good
    gyp verb get node dir target node version installed: 8.11.1
    gyp verb build dir attempting to create "build" dir:
    /Working/ionicV2/live-run2/node_modules/node-sass/build
    gyp ERR! configure error
    gyp ERR! stack Error: EACCES: permission denied, mkdir
    '/Working/ionicV2/live-run2/node_modules/node-sass/build'
    gyp ERR! System Darwin 17.4.0
    gyp ERR! command "/usr/local/bin/node"
    "/Working/ionicV2/live-run2/node_modules/node-gyp/bin/node-gyp.js"
    "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags="
    "--libsass_ldflags=" "--libsass_library="
    gyp ERR! cwd /Working/ionicV2/live-run2/node_modules/node-sass
    gyp ERR! node -v v8.11.1
    gyp ERR! node-gyp -v v3.6.2
    gyp ERR! not ok
    Build failed with error code: 1
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! node-sass@4.7.2 postinstall: `node scripts/build.js`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the node-sass@4.7.2 postinstall script.
    npm ERR! This is probably not a problem with npm. There is likely
    additional logging output above.

    npm ERR! A complete log of this run can be found in:
    npm ERR!

FROM the log file, I can see followings:

21613 verbose stack Error: node-sass@4.7.2 postinstall: node scripts/build.js
21613 verbose stack Exit status 1
21613 verbose stack at EventEmitter. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
21613 verbose stack at emitTwo (events.js:126:13)
21613 verbose stack at EventEmitter.emit (events.js:214:7)
21613 verbose stack at ChildProcess. (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
21613 verbose stack at emitTwo (events.js:126:13)
21613 verbose stack at ChildProcess.emit (events.js:214:7)
21613 verbose stack at maybeClose (internal/child_process.js:925:16)
21613 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
21614 verbose pkgid node-sass@4.7.2
21615 verbose cwd /Working/ionicV2/live-run2
21616 verbose Darwin 17.4.0
21617 verbose argv “/usr/local/bin/node” “/usr/local/bin/npm” “i”
21618 verbose node v8.11.1
21619 verbose npm v5.6.0
21620 error code ELIFECYCLE
21621 error errno 1
21622 error node-sass@4.7.2 postinstall: node scripts/build.js
21622 error Exit status 1
21623 error Failed at the node-sass@4.7.2 postinstall script.
21623 error This is probably not a problem with npm. There is likely additional logging output above.
21624 verbose exit [ 1, true ]


#2

One problem is that you should never run npm with elevated privileges (aka under sudo). Use nvm instead. Once you have ever run npm as root, it is challenging if not impossible for anybody to explain how to undo what has been done and get your system into a usable state. It is only a slight exaggeration to say that you might need to completely reinstall your OS in order to fix this.


#3

try cleaning npm cache
npm cache clean -f


#4

Thank all for your response, but it did not work at all, I tried three different computers, including windows. No idea the actual issue, this is the first time I am seeing such problem with ionic cli.


#5

try this commands.

sudo npm install --save-dev rebuild-node-sass node-sass

sudo npm install --unsafe-perm -g node-sass

sudo npm install -g --unsafe-perm --verbose @angular/cli

sudo npm install -g @angular/cli@latest --unsafe-perm


#6

I had the same issue everytime when i run project which is created in a different machine. Fixing the npm permissions in the global level solved my problem. hope this helps for your as well.
https://docs.npmjs.com/getting-started/fixing-npm-permissions