【问题标题】:Unable to create ionic 3 project无法创建 ionic 3 项目
【发布时间】:2023-11-03 04:03:02
【问题描述】:

我正在通过以下命令创建一个 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

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

【问题讨论】:

  • 能否请您发布 $ionic 信息和 npm 版本详细信息?

标签: ionic-framework npm ionic3 sudo


【解决方案1】:

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

【讨论】:

  • 好的,我会检查并告诉你
【解决方案2】:

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

查看此链接了解步骤 https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally

【讨论】:

  • 好的,我会检查并告诉你