Upgrading to ionic v2.0.0 issues

2019-09-12 11:45发布

问题:

My project was originally built using:

  • ionic: 2.0.0-rc.3
  • ionic-app-scripts: 0.0.45

After upgrading to:

  • ionic: 2.0.0 (which just looks like 2.0.0-rc.6)
  • ionic-app-scripts: 1.0.0

I'm encountering lots of errors:

I've reviewed the ionic changelog and the ionic-app-scripts one but nothing stands out.

I'm assuming the errors are to do with ionic-app-scripts (as that's the directory in node_modules) it's looking at but I'm not sure what it could be.

When running ionic info:

Cordova CLI: 6.5.0
Ionic Framework Version: 2.0.0
Ionic CLI Version: 2.2.1
Ionic App Lib Version: 2.2.0
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 10
Node Version: v7.4.0
Xcode version: Not installed

EDIT:

This is my package.json:

"dependencies": {
    "@angular/common": "2.4.5",
    "@angular/compiler": "2.4.5",
    "@angular/compiler-cli": "2.4.5",
    "@angular/core": "2.4.5",
    "@angular/forms": "2.4.5",
    "@angular/http": "2.4.5",
    "@angular/platform-browser": "2.4.5",
    "@angular/platform-browser-dynamic": "2.4.5",
    "@angular/platform-server": "2.4.5",
    "@ionic/storage": "1.1.7",
    "@types/jasmine": "^2.5.40",
    "@types/lodash": "^4.14.50",
    "angular2-google-maps": "0.17.0",
    "angularfire2": "^2.0.0-beta.6",
    "clean-css": "^4.0.2",
    "firebase": "^3.6.4",
    "ionic-angular": "2.0.0",
    "ionic-native": "2.4.1",
    "ionicons": "3.0.0",
    "lodash": "^4.17.4",
    "rxjs": "^5.0.0-beta.12",
    "zone.js": "0.7.6"
},
"devDependencies": {
    "@ionic/app-scripts": "1.0.0",
    "typescript": "2.1.5"
},

EDIT #2:

If I copy the packages.json from a working template to my project (and do a fresh install of node_modules) I get the same error as before. It is clearly an error with @ionic/app-scripts as I have run npm run build (as described here) and that's where the error(s) appear.

Since the error(s) only came when I copied in my src folder, it must be something to with my project as it was written with 0.0.45 and not 1.0.0 of @ionic/app-scripts. Is there a possible way to debug and find where the error is?

Also (even though the out-the-box template works), when going into clean-css-factory.d.ts and virtual-file-utils.d.ts, the same errors are there even though it builds and runs just fine?

Note: When running npm run build, the console logs up until:

> ionic-hello-world@ build   E:\Documents\Year_3\Mobile_Application_Development\mammoth-v2
> ionic-app-scripts build

[15:41:38]  ionic-app-scripts 1.0.0
[15:41:38]  build dev started ...
[15:41:38]  clean started ...
[15:41:38]  clean finished in 3 ms
[15:41:38]  copy started ...
[15:41:38]  transpile started ...

            **errors occur from here**

SOLUTION:

I have found a solution to the original problem. There was an unused import of a module that no longer exists (due to the new version of @ionic/app-scripts) which was:

import { transformSrcPathToTmpPath } from "@ionic/app-scripts/dist";

回答1:

Have you tried Deleting node Modules ?

rm -rf node_modules

Do you have the latest cli ?

npm uninstall -g ionic
npm install -g ionic

Change your package.json to the following

"dependencies": {
    "@angular/common": "2.2.1",
    "@angular/compiler": "2.2.1",
    "@angular/compiler-cli": "2.2.1",
    "@angular/core": "2.2.1",
    "@angular/forms": "2.2.1",
    "@angular/http": "2.2.1",
    "@angular/platform-browser": "2.2.1",
    "@angular/platform-browser-dynamic": "2.2.1",
    "@angular/platform-server": "2.2.1",
    "@ionic/storage": "1.1.7",
    "ionic-angular": "2.0.0-rc.5",
    "ionic-native": "2.2.11",
    "ionicons": "3.0.0",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.26",
    "sw-toolbox": "3.4.0"
  },
  "devDependencies": {
    "@ionic/app-scripts": "1.0.0",
    "typescript": "2.0.9"
  }

As a last resort you can create a new ionic application then move all your code

ionic start newApp --v2 --ts


回答2:

The solution was that I had an unused import looking for a module in @ionic/app-scripts that no longer existed (was from 0.0.45 and doesn't exist in 1.0.0).
The module it was looking for was transformSrcPathToTmpPath in @ionic/app-scripts/dist