首页 > 解决方案 > 我在运行 Ionic 应用程序时遇到错误

问题描述

在我的 Mac 中运行命令>sudo ionic serve后,我得到 -:

ionic-app-scripts 服务 --address 0.0.0.0 --port 8100 --livereload-port 35729 --dev-logger-port 53703 --nobrowser

[INFO] 看起来这个项目中没有安装@ionic/app-scripts。

   This package is required for this command to work properly.

? 安装@ionic/app-scripts?是的

当我开始使用 cli command > npm i -D -E @ionic/app-scripts安装它时, 我得到-:

npm WARN deprecated hoek@2.16.3: The major version is no longer supported. Please update to 4.x or newer

> node-sass@4.9.0 install /Users/user/Projects/MyIonicProject/node_modules/node-sass
> node scripts/install.js

Unable to save binary /Users/user/Projects/MyIonicProject/node_modules/node-sass/vendor/darwin-x64-64 : { Error: EACCES: permission denied, mkdir '/Users/user/Projects/MyIonicProject/node_modules/node-sass/vendor'
    at Object.fs.mkdirSync (fs.js:854:3)
    at sync (/Users/user/Projects/MyIonicProject/node_modules/mkdirp/index.js:71:13)
    at Function.sync (/Users/user/Projects/MyIonicProject/node_modules/mkdirp/index.js:77:24)
    at checkAndDownloadBinary (/Users/user/Projects/MyIonicProject/node_modules/node-sass/scripts/install.js:114:11)
    at Object.<anonymous> (/Users/user/Projects/MyIonicProject/node_modules/node-sass/scripts/install.js:157:1)
    at Module._compile (internal/modules/cjs/loader.js:678:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:689:10)
    at Module.load (internal/modules/cjs/loader.js:589:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:528:12)
    at Function.Module._load (internal/modules/cjs/loader.js:520:3)
  errno: -13,
  syscall: 'mkdir',
  code: 'EACCES',
  path: '/Users/user/Projects/MyIonicProject/node_modules/node-sass/vendor' }

> node-sass@4.9.0 postinstall /Users/user/Projects/MyIonicProject/node_modules/node-sass
> node scripts/build.js

Building: /usr/local/bin/node /Users/user/Projects/MyIonicProject/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   '/Users/user/Projects/MyIonicProject/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@10.1.0 | 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 (/Users/user/Projects/MyIonicProject/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/Users/user/Projects/MyIonicProject/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/Users/user/Projects/MyIonicProject/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /Users/user/Projects/MyIonicProject/node_modules/which/which.js:89:16
gyp verb `which` failed     at /Users/user/Projects/MyIonicProject/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /Users/user/Projects/MyIonicProject/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:165:21)
gyp verb `which` failed  python2 { Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/Users/user/Projects/MyIonicProject/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/Users/user/Projects/MyIonicProject/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/Users/user/Projects/MyIonicProject/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /Users/user/Projects/MyIonicProject/node_modules/which/which.js:89:16
gyp verb `which` failed     at /Users/user/Projects/MyIonicProject/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /Users/user/Projects/MyIonicProject/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqWrap.oncomplete (fs.js:165:21)
gyp verb `which` failed   stack: 'Error: not found: python2\n    at getNotFoundError (/Users/user/Projects/MyIonicProject/node_modules/which/which.js:13:12)\n    at F (/Users/user/Projects/MyIonicProject/node_modules/which/which.js:68:19)\n    at E (/Users/user/Projects/MyIonicProject/node_modules/which/which.js:80:29)\n    at /Users/user/Projects/MyIonicProject/node_modules/which/which.js:89:16\n    at /Users/user/Projects/MyIonicProject/node_modules/isexe/index.js:42:5\n    at /Users/user/Projects/MyIonicProject/node_modules/isexe/mode.js:8:5\n    at FSReqWrap.oncomplete (fs.js:165: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 sys; print "2.7.10
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir no --target version specified, falling back to host node version: 10.1.0
gyp verb command install [ '10.1.0' ]
gyp verb install input version string "10.1.0"
gyp verb install installing version: 10.1.0
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: 10.1.0
gyp verb build dir attempting to create "build" dir: /Users/user/Projects/MyIonicProject/node_modules/node-sass/build
gyp ERR! configure error 
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/user/Projects/MyIonicProject/node_modules/node-sass/build'
gyp ERR! System Darwin 15.4.0
gyp ERR! command "/usr/local/bin/node" "/Users/user/Projects/MyIonicProject/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/user/Projects/MyIonicProject/node_modules/node-sass
gyp ERR! node -v v10.1.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 
Build failed with error code: 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass@4.9.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-sass@4.9.0 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!     /Users/user/.npm/_logs/2018-09-21T07_51_45_171Z-debug.log
[ERROR] An error occurred while running subprocess npm.

        npm i -D -E @ionic/app-scripts exited with exit code 1.

        Re-running this command with the --verbose flag may provide more 
        information.
users-MacBook-Pro-3:MyIonicProject user$ 

正如您在上面看到的,我收到了错误,我将上面代码的一些错误部分放在下面,请查看:

吉普错误!cwd /Users/user/Projects/MyIonicProject/node_modules/node-sass gyp 错误!节点 -v v10.1.0 gyp 错误!节点-gyp -v v3.8.0 gyp 错误!不好构建失败,错误代码:1 npm ERR!代码 ELIFECYCLE npm 错误!errno 1 npm 错误!node-sass@4.9.0 安装后:node scripts/build.jsnpm 错误!退出状态 1 npm ERR!npm 错误!在 node-sass@4.9.0 安装后脚本失败。npm 错误!这可能不是 npm 的问题。上面可能有额外的日志输出。

npm 错误!可以在以下位置找到此运行的完整日志:npm ERR!
/Users/user/.npm/_logs/2018-09-21T07_51_45_171Z-debug.log [错误] 运行子进程 npm 时出错。

    npm i -D -E @ionic/app-scripts exited with exit code 1.

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

我在这里遇到错误......并且无法运行我的离子应用程序,我还删除并重新安装了 npm 但它对我不起作用请帮助我

标签: ionic-frameworkionic3sourceforge-appscript

解决方案


您收到“EACCESS”错误,这可能与权限不足有关。尝试像这样更改项目目录的所有者:

sudo chown -R user:user /Users/user/Projects/MyIonicProject

然后:

npm i -D -E @ionic/app-scripts

推荐阅读