在Ionic Cli版本之间切换?

时间:2018-09-10 16:03:46

标签: ionic-framework ionic4 ionic-cli

我正在从事多个项目,其中一些使用Ionic 1,另一些使用Ionic4。但是,在它们之间进行切换已成为一个问题。在将Ionic CLI更新到最新版本并使用4以后,我现在尝试在较旧的Ionic 1上工作。

问题是每次我运行ionic serve都会得到以下信息:

Error: spawn ENOTDIR

at _errnoException (util.js:1024:11)
at ChildProcess.spawn (internal/child_process.js:323:11)
at Object.exports.spawn (child_process.js:502:9)
at spawn (/usr/local/lib/node_modules/ionic/node_modules/cross-spawn/index.js:17:18)
at spawn (/usr/local/lib/node_modules/ionic/node_modules/@ionic/cli-framework/utils/shell.js:124:12)
at ShellCommand.spawn (/usr/local/lib/node_modules/ionic/node_modules/@ionic/cli-framework/utils/shell.js:113:16)
at Shell.spawn (/usr/local/lib/node_modules/ionic/node_modules/@ionic/cli-utils/lib/shell.js:136:23)
at Ionic1ServeCLI.<anonymous> (/usr/local/lib/node_modules/ionic/node_modules/@ionic/cli-utils/lib/serve.js:398:36)
at Generator.next (<anonymous>)
at fulfilled (/usr/local/lib/node_modules/ionic/node_modules/tslib/tslib.js:104:62)

我尝试了各种解决方案,例如thisthisthis,但是没有运气。

我也尝试过更新我的npm依赖项,但是没有运气。

 cordova                             ^7.1.0  →  ^8.0.0 
 cordova-android                     ^6.3.0  →  ^7.1.1 
 cordova-plugin-device               ^1.1.7  →  ^2.0.2 
 cordova-plugin-file                 ^5.0.0  →  ^6.0.1 
 cordova-plugin-inappbrowser         ^1.7.2  →  ^3.0.0 
 cordova-plugin-network-information  ^1.3.4  →  ^2.0.1 
 cordova-plugin-screen-orientation   ^2.0.2  →  ^3.0.1 
 cordova-plugin-splashscreen         ^4.1.0  →  ^5.0.2 
 gulp-sass                           ^3.1.0  →  ^4.0.1 

据我所知文档显示最新的CLI向后兼容。

编辑:

离子信息:

Ionic:

   ionic (Ionic CLI) : 4.1.2 (/usr/local/lib/node_modules/ionic)
   Ionic Framework   : ionic1 1.3.3
   @ionic/v1-toolkit : not installed

Cordova:

   cordova (Cordova CLI) : 8.0.0
   Cordova Platforms     : android 6.3.0
   Cordova Plugins       : no whitelisted plugins (13 plugins total)

System:

   Android SDK Tools : 26.1.1 (/Users/jrquick/Library/Android/sdk)
   NodeJS            : v8.9.2 (/usr/local/bin/node)
   npm               : 6.4.1
   OS                : macOS High Sierra

1 个答案:

答案 0 :(得分:0)

显然,为了支持最新的Ionic CLI,ionic1项目中需要进行一些更改。为了解决这个问题,我更新了最新的Ionic(sudo npm install -g ionic@latest),创建了一个临时项目(ionic start myproject --type ionic1),然后比较文件以查看发生了什么变化。

我的步骤(请参见下面的示例)

  1. 将ionic-bower更新为1.3.4(在bower.json中找到)
  2. 删除gulpStartupTasks并更新watchPatterns(可在ionic.config.json中找到)。
  3. 创建ionic.starter.json
  4. 安装@ ionic / v1-toolkit并更新gulp devDependencies(位于package.json中)
  5. rm -f package-lock.json && rm -rf node_modules/ && rm -rf www/lib/ && npm install && bower install
  6. ionic serve

示例(更新的文件)

bower.json

{
  "name": "r01",
  "private": true,
  "devDependencies": {
    "ionic": "driftyco/ionic-bower#1.3.4"
  },
  "authors": [
    "jrquick <>"
  ],
  "description": "",
  "main": "",
  "license": "",
  "homepage": "",
  "dependencies": {
    "ngCordova": "^0.1.27-alpha",
    "ionic-toast": "^0.4.1",
    "angular-perfect-scrollbar": "^0.2.1",
    "ionic-calendar": "^0.3.8",
    "ionic-color-picker": "^1.0.3"
  }
}

ionic.config.json

{
  "name": "r01",
  "integrations": {
    "cordova": {},
    "gulp": {}
  },
  "watchPatterns": [
      "scss/**/*",
      "www/**/*",
      "!www/lib/**/*",
      "!www/**/*.map"
  ],
  "type": "ionic1",
  "pro_id": ""
}

ionic.starter.json

{
  "name": "r01",
  "baseref": "master"
}

package.json

{
  "name": "r01",
  "version": "2.6.3",
  "description": "",
  "dependencies": {
    "cordova": "^8.0.0",
    "cordova-android": "^7.1.1",
    "cordova-externalstoragepath-plugin": "^1.0.4",
    "cordova-ios": "~4.5.5",
    "cordova-plugin-compat": "^1.2.0",
    "cordova-plugin-console": "^1.1.0",
    "cordova-plugin-device": "^2.0.2",
    "cordova-plugin-exclude-files": "^0.4.1",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-inappbrowser": "^3.0.0",
    "cordova-plugin-network-information": "^2.0.1",
    "cordova-plugin-screen-orientation": "^3.0.1",
    "cordova-plugin-splashscreen": "^5.0.2",
    "cordova-plugin-statusbar": "^2.4.2",
    "cordova-plugin-whitelist": "^1.3.3",
    "es6-promise-plugin": "^4.2.2",
    "ionic-plugin-keyboard": "^2.2.1"
  },
  "devDependencies": {
    "@ionic/v1-toolkit": "^1.0.0",
    "gulp": "^3.5.6",
    "gulp-clean-css": "^3.7.0",
    "gulp-rename": "^1.2.0",
    "gulp-sass": "^3.1.0",
    "ionic-minify": "^2.0.10"
  },
  "cordovaPlugins": [
    "cordova-plugin-device",
    "cordova-plugin-console",
    "cordova-plugin-whitelist",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "ionic-plugin-keyboard"
  ],
  "cordovaPlatforms": [],
  "main": "gulpfile.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "[PRIVATE REPO]"
  },
  "author": "jrquick <>",
  "homepage": "[PRIVATE HOMEPAGE]",
  "cordova": {
    "plugins": {
      "cordova-plugin-console": {},
      "cordova-plugin-device": {},
      "cordova-plugin-network-information": {},
      "cordova-plugin-screen-orientation": {},
      "cordova-plugin-splashscreen": {},
      "cordova-plugin-statusbar": {},
      "cordova-plugin-whitelist": {},
      "ionic-plugin-keyboard": {},
      "cordova-plugin-file": {},
      "cordova-externalstoragepath-plugin": {},
      "cordova-plugin-inappbrowser": {},
      "cordova-plugin-exclude-files": {}
    },
    "platforms": [
      "android"
    ]
  }
}
相关问题