使用 Ionic 创建应用程序时显示错误
Posted
技术标签:
【中文标题】使用 Ionic 创建应用程序时显示错误【英文标题】:Showing error while creating app using Ionic 【发布时间】:2022-01-14 23:17:47 【问题描述】:这里是代码
E:\Programming\android app development>ionic start Demo blank --type ionic1
√ Preparing directory .\Demo in 2.92ms
√ Downloading and extracting blank starter in 1.80s
? Integrate your new app with Capacitor to target native ios and Android? Yes
> ionic integrations enable capacitor --quiet -- Demo io.ionic.starter
> npm.cmd i --save -E @capacitor/core@latest
npm WARN deprecated natives@1.1.6: This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x.
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm ERR! code 1
npm ERR! path E:\Programming\Android app development\Demo\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe E:\Programming\Android app development\Demo\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli 'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli 'E:\\Programming\\Android app development\\Demo\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli 'rebuild',
npm ERR! gyp verb cli '--verbose',
npm ERR! gyp verb cli '--libsass_ext=',
npm ERR! gyp verb cli '--libsass_cflags=',
npm ERR! gyp verb cli '--libsass_ldflags=',
npm ERR! gyp verb cli '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.13.1 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (E:\Programming\Android app development\Demo\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed at F (E:\Programming\Android app development\Demo\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed at E (E:\Programming\Android app development\Demo\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed at E:\Programming\Android app development\Demo\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` f`enter code here`ailed at E:\Programming\Android app development\Demo\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed at E:\Programming\Android app development\Demo\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed python2 Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (E:\Programming\Android app development\Demo\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed at F (E:\Programming\Android app development\Demo\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed at E (E:\Programming\Android app development\Demo\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed at E:\Programming\Android app development\Demo\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed at E:\Programming\Android app development\Demo\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed at E:\Programming\Android app development\Demo\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed code: 'ENOENT'
npm ERR! gyp verb `which` failed
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python C:\Users\samprithazra\AppData\Local\Programs\Python\Python310\python.EXE
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: C:\Users\samprithazra\AppData\Local\Programs\Python\Python310\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack File "<string>", line 1
npm ERR! gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm ERR! gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:397:12)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1064:16)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "E:\\Programming\\Android app development\\Demo\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd E:\Programming\Android app development\Demo\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.13.1
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\samprithazra\AppData\Local\npm-cache\_logs\2021-12-10T07_18_12_049Z-debug-0.log
[ERROR] An error occurred while running subprocess npm.
npm.cmd i --save -E @capacitor/core@latest exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
Installing dependencies may take several minutes.
──────────────────────────────────────────────────────────────────────
Ionic Enterprise, platform and solutions for teams by Ionic
Powerful library of native APIs
A supercharged platform for teams
Learn more: https://ion.link/enterprise
──────────────────────────────────────────────────────────────────────
> npm.cmd i
npm WARN deprecated natives@1.1.6: This module relies on Node.js's internals and will break at some point. Do not use it, and update to graceful-fs@4.x.
npm WARN deprecated minimatch@2.0.10: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated har-validator@5.1.5: this library is no longer supported
npm WARN deprecated graceful-fs@1.2.3: please upgrade to graceful-fs 4 for compatibility with current and future versions of Node.js
npm WARN deprecated chokidar@2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated minimatch@0.2.14: Please update to minimatch 3.0.2 or higher to avoid a RegExp DoS issue
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated request@2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated tar@2.2.2: This version of tar is no longer supported, and will not receive security updates. Please upgrade asap.
npm ERR! code 1
npm ERR! path E:\Programming\Android app development\Demo\node_modules\node-sass
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c node scripts/build.js
npm ERR! Building: C:\Program Files\nodejs\node.exe E:\Programming\Android app development\Demo\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli 'C:\\Program Files\\nodejs\\node.exe',
npm ERR! gyp verb cli 'E:\\Programming\\Android app development\\Demo\\node_modules\\node-gyp\\bin\\node-gyp.js',
npm ERR! gyp verb cli 'rebuild',
npm ERR! gyp verb cli '--verbose',
npm ERR! gyp verb cli '--libsass_ext=',
npm ERR! gyp verb cli '--libsass_cflags=',
npm ERR! gyp verb cli '--libsass_ldflags=',
npm ERR! gyp verb cli '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp@3.8.0
npm ERR! gyp info using node@16.13.1 | win32 | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (E:\Programming\Android app development\Demo\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed at F (E:\Programming\Android app development\Demo\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed at E (E:\Programming\Android app development\Demo\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed at E:\Programming\Android app development\Demo\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed at E:\Programming\Android app development\Demo\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed at E:\Programming\Android app development\Demo\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed python2 Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (E:\Programming\Android app development\Demo\node_modules\which\which.js:13:12)
npm ERR! gyp verb `which` failed at F (E:\Programming\Android app development\Demo\node_modules\which\which.js:68:19)
npm ERR! gyp verb `which` failed at E (E:\Programming\Android app development\Demo\node_modules\which\which.js:80:29)
npm ERR! gyp verb `which` failed at E:\Programming\Android app development\Demo\node_modules\which\which.js:89:16
npm ERR! gyp verb `which` failed at E:\Programming\Android app development\Demo\node_modules\isexe\index.js:42:5
npm ERR! gyp verb `which` failed at E:\Programming\Android app development\Demo\node_modules\isexe\windows.js:36:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed code: 'ENOENT'
npm ERR! gyp verb `which` failed
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python C:\Users\samprithazra\AppData\Local\Programs\Python\Python310\python.EXE
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: C:\Users\samprithazra\AppData\Local\Programs\Python\Python310\python.EXE -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack File "<string>", line 1
npm ERR! gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
npm ERR! gyp ERR! stack SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:397:12)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:390:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1064:16)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
npm ERR! gyp ERR! System Windows_NT 10.0.19042
npm ERR! gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "E:\\Programming\\Android app development\\Demo\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd E:\Programming\Android app development\Demo\node_modules\node-sass
npm ERR! gyp ERR! node -v v16.13.1
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\samprithazra\AppData\Local\npm-cache\_logs\2021-12-10T07_18_59_237Z-debug-0.log
[ERROR] An error occurred while running subprocess npm.
npm.cmd i exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
E:\Programming\Android app development>
如何解决这个问题?我在 Windows 10 64 位中运行 Nodejs 16.13.1。 我想可能是 Nodejs 版本的问题。但在我这边,我没有发现任何问题。我很高兴知道那里有什么问题。
【问题讨论】:
确保你有推荐的 node js 版本 如何查看推荐的node js版本https://nodejs.org/en/
,下载 LTS 是推荐的版本,并确保你有与它兼容的电容器,所以最好的情况是卸载 ionic 然后用电容器@latest 再次下载它,因为确定它将与推荐的 nodejs 兼容
您添加了 ionic1 标志。那将不得不使用非常旧的包,我确信 Node 16 不支持 AngularJS。如果你想使用 Ionic v1,你需要将它 Dockerize 并像 Node 6 一样使用。
我现在已经解决了这个问题,我使用的是 node js 14.16.1。然后它解决了这个问题。
【参考方案1】:
NodeJS 依赖于在 Python 上运行的 GYP。 您需要确保系统中安装的 python 版本与您的 GYP 版本兼容。
由于在 GYP 执行期间出现以下 Python 错误,您的构建失败:
import sys; print "%s.%s.%s" % sys.version_info[:3];
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
这是very classic issue,这通常意味着您正在尝试使用 python3.x 解释器运行 python2.x 脚本。
需要保证node版本、gyp版本、python版本都兼容。
目前您正在尝试构建:
节点 v16.13.1 gyp v3.8.0 python v3.x?我相信 GYP 仅支持从 v5.0.5 开始的 Python 3.x。您需要更新 GYP 和 NPM 或使用 python2.7。
【讨论】:
我已经通过将我的 Node js 版本降级到 14.16.1 解决了这个问题。感谢您的回答以上是关于使用 Ionic 创建应用程序时显示错误的主要内容,如果未能解决你的问题,请参考以下文章
Ionic Angular Mobile App 在从项目中的文件中获取和显示 json-array 数据时显示错误---
当我尝试在我的 Android 设备上预览我的应用程序时显示错误