0

我正在处理多个项目,其中一些使用 Ionic 1,另一些使用 Ionic 4。但是,在它们之间切换已经成为一个问题。在将 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)

我已经尝试了各种解决方案,例如这个这个这个,但没有运气。

我也尝试过更新我的 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
4

1 回答 1

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

示例(更新文件)

鲍尔.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"
}

包.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"
    ]
  }
}
于 2018-09-10T17:05:02.640 回答