我是框架ionic cordova
的新手,遇到了问题。我从一位同事那里获得了一个项目,应该为ios
创建它。创建iOS平台时,立即发生错误:
Heikos-MacBook-Pro:project_app premox$ ionic cordova build ios --prod
Using cordova-fetch for cordova-ios@4.5.5
Adding ios project...
Creating Cordova project for the iOS platform:
Path: platforms/ios
Package: com.project
Name: Project.com
iOS project created with cordova-ios@4.5.5
Installing "cordova-plugin-add-swift-support" for ios
Installing "cordova-plugin-android-permissions" for ios
Installing "cordova-plugin-device" for ios
Installing "cordova-plugin-globalization" for ios
Installing "cordova-plugin-inappbrowser" for ios
Installing "cordova-plugin-ionic-webview" for ios
Installing "cordova-plugin-ios-camera-permissions" for ios
Installing "cordova-plugin-qrscanner" for ios
Plugin dependency "cordova-plugin-add-swift-support@1.7.2" already fetched, using that version.
Dependent plugin "cordova-plugin-add-swift-support" already installed on ios.
Installing "cordova-plugin-splashscreen" for ios
Installing "cordova-plugin-whitelist" for ios
Installing "ionic-plugin-keyboard" for ios
Discovered saved plugin "cordova-sqlite-storage". Adding it to the project
Installing "cordova-sqlite-storage" for ios
Failed to install 'cordova-sqlite-storage': CordovaError: Using "requireCordovaModule" to load non-cordova module "q" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
at Context.requireCordovaModule (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/Context.js:57:15)
at module.exports (/Users/premox/Documents/projects/project_app/plugins/cordova-sqlite-storage/scripts/beforePluginInstall.js:13:21)
at runScriptViaModuleLoader (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:181:32)
at runScript (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:157:16)
at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:125:20
at processTicksAndRejections (internal/process/task_queues.js:89:5)
Failed to restore plugin "cordova-sqlite-storage" from config.xml. You might need to try adding it again. Error: Using "requireCordovaModule" to load non-cordova module "q" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
Discovered saved plugin "cordova-plugin-statusbar". Adding it to the project
Installing "cordova-plugin-statusbar" for ios
Adding cordova-plugin-statusbar to package.json
Failed to restore plugin "cordova-plugin-statusbar" from config.xml. You might need to try adding it again. Error: Using "requireCordovaModule" to load non-cordova module "glob" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
Using "requireCordovaModule" to load non-cordova module "glob" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
[ERROR] An error occurred while running subprocess cordova.
cordova platform add ios --save exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
我用--verbose
重复了通话,并收到以下错误消息:
Heikos-MacBook-Pro:project_app premox$ ionic cordova build ios --prod --verbose
ionic:lib Terminal info: { tty: true, ci: false, windows: false } +0ms
ionic:lib CLI global options: { _: [ 'cordova', 'build', 'ios' ], help: null, h: null, verbose: true, quiet: null, interactive: true, color: true, confirm: null, json: null, prod: true, project: null, '--': [] } +10ms
ionic:lib:project Project type from config: Ionic 2/3 (ionic-angular) +0ms
ionic:lib:project Project details: { configPath: '/path/to/project/ionic.config.json', errors: [], context: 'app', type: 'ionic-angular' } +0ms
ionic Context: { binPath: '/usr/local/lib/node_modules/ionic/bin/ionic', libPath: '/usr/local/lib/node_modules/ionic', execPath: '/path/to/project', version: '4.12.0' } +0ms
ionic:lib:integrations:cordova:config Using config.xml: /path/to/project/config.xml +0ms
ionic:lib:telemetry Sending telemetry for command: 'ionic cordova build' [ 'ios', '--prod', '--verbose', '--interactive', '--color' ] +0ms
ionic:lib:hooks Looking for ionic:build:before npm script. +0ms
ionic:lib:project:ionic-angular:build Looking for ionic:build npm script. +0ms
ionic:lib:project:ionic-angular:build Found ionic:build, but it is the default. Not running. +13ms
> ionic-app-scripts build --prod --target cordova --platform ios
/path/to/project/node_modules/node-sass/lib/binding.js:13
throw new Error(errors.unsupportedEnvironment());
^
Error: Node Sass does not yet support your current environment: OS X 64-bit with Unsupported runtime (72)
For more information on which environments are supported please see:
https://github.com/sass/node-sass/releases/tag/v4.5.3
at module.exports (/path/to/project/node_modules/node-sass/lib/binding.js:13:13)
at Object.<anonymous> (/path/to/project/node_modules/node-sass/lib/index.js:14:35)
at Module._compile (internal/modules/cjs/loader.js:774:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:785:10)
at Module.load (internal/modules/cjs/loader.js:641:32)
at Function.Module._load (internal/modules/cjs/loader.js:556:12)
at Module.require (internal/modules/cjs/loader.js:681:19)
at require (internal/modules/cjs/helpers.js:16:16)
at Object.<anonymous> (/path/to/project/node_modules/@ionic/app-scripts/dist/core/bundle-components.js:6:16)
at Module._compile (internal/modules/cjs/loader.js:774:30)
[ERROR] An error occurred while running subprocess ionic-app-scripts.
ionic-app-scripts build --prod --target cordova --platform ios exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
ionic:utils-process onBeforeExit handler: process.exit received +0ms
ionic:utils-process onBeforeExit handler: running 1 functions +1ms
ionic:utils-process onBeforeExit handler: exiting (exit code 1) +71ms
我不太了解此错误消息。这是什么意思,我该如何解决?
我卸载了cordova-sqlite-storage
插件,并希望重新安装它,并收到以下消息:
Heikos-MacBook-Pro:project_app premox$ ionic cordova plugin rm cordova-sqlite-storage
> cordova plugin remove cordova-sqlite-storage --save
Uninstalling cordova-sqlite-storage from ios
Removing "cordova-sqlite-storage"
Removing cordova-sqlite-storage from package.json
Heikos-MacBook-Pro:project_app premox$ cordova plugin add cordova-sqlite-storage@latest
^C
Heikos-MacBook-Pro:project_app premox$ ionic cordova plugin add cordova-sqlite-storage@latest
> cordova plugin add cordova-sqlite-storage@latest --save
Installing "cordova-sqlite-storage" for ios
installing external dependencies via npm
for package name: cordova-sqlite-storage
npm install of external dependencies ok
Adding cordova-sqlite-storage to package.json
Using "requireCordovaModule" to load non-cordova module "glob" is not supported. Instead, add this module to your dependencies and use regular "require" to load it.
[ERROR] An error occurred while running subprocess cordova.
cordova plugin add cordova-sqlite-storage@latest --save exited with exit code 1.
Re-running this command with the --verbose flag may provide more information.
答案 0 :(得分:1)
因为您使用的是Cordova 9,Cordova 9现在不支持q模块。
您有2个解决方案:
尝试将cordova-sqlite-storage更新到最新版本。
或将您的Cordova版本降级到8。
npm install -g cordova@8.1.1
答案 1 :(得分:0)
我刚刚将关键字requireCordovaModule
更改为require
,事情开始起作用。