无法创建ionic 3项目

时间:2018-12-18 06:52:54

标签: ionic-framework npm ionic3 sudo

我正在通过以下命令创建ionic v2项目:

sudo ionic start demoApp blank --V2

但是鉴于以下cmd错误,我正在使用iMac。

  npm WARN deprecated browserslist@2.11.3: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.

> fsevents@1.2.4 install /demoApp/node_modules/fsevents
> node install

[fsevents] Success: "/demoApp/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.11.0 install /demoApp/node_modules/node-sass
> node scripts/install.js

Unable to save binary /demoApp/node_modules/node-sass/vendor/darwin-x64-57 : { Error: EACCES: permission denied, mkdir '/demoApp/node_modules/node-sass/vendor'
    at Object.fs.mkdirSync (fs.js:885:18)
    at sync (/demoApp/node_modules/mkdirp/index.js:71:13)
    at Function.sync (/demoApp/node_modules/mkdirp/index.js:77:24)
    at checkAndDownloadBinary (/demoApp/node_modules/node-sass/scripts/install.js:114:11)
    at Object.<anonymous> (/demoApp/node_modules/node-sass/scripts/install.js:157: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: '/demoApp/node_modules/node-sass/vendor' }

> uglifyjs-webpack-plugin@0.4.6 postinstall /demoApp/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js


> node-sass@4.11.0 postinstall /demoApp/node_modules/node-sass
> node scripts/build.js

Building: /usr/local/bin/node /demoApp/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   '/demoApp/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.8.0
gyp info using node@8.11.4 | 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
        npm i exited with exit code 1.

        Re-running this command with the --verbose flag may provide more information.

我已经授予权限并运行以下命令:

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

 sudo npm install -g node-sass

请建议我如何解决此类错误和权限。

2 个答案:

答案 0 :(得分:0)

登录的用户可能不是NPM目录的所有者。参见this

答案 1 :(得分:0)

我已经将ionic CLI升级到了最新版本,并且对ionic2项目也遇到了同样的问题。将npm的默认目录更改为全局目录,即可解决所有问题。

检查此链接以获取步骤 https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally