Search code examples
nativescriptupgradenativescript-angular

How to upgrade to NativeScript 5?


I have a mobile app on NativeScript 4.2 with Angular. How do I upgrade to NativeScript 5.0?

I also would like to start using the preview app from the NativeScript CLI.


Solution

  • Follow the upgrade instructions at https://docs.nativescript.org/releases/upgrade-instructions. The page also has a link to breaking changes.

    Here's a summary of the commands.

    # NativeScript CLI
    npm install -g nativescript
    
    # Application Upgrade
    tns update
    
    # Platform Upgrade
    tns platform remove android
    tns platform add android
    tns platform remove ios
    tns platform add ios
    
    # tns-core-modules Upgrade
    npm install tns-core-modules@latest --save
    
    # TypeScript Upgrade
    npm i nativescript-dev-typescript@latest --save-dev
    ./node_modules/.bin/ns-upgrade-tsconfig
    
    # Angular Upgrade
    npm i nativescript-angular@latest --save
    ./node_modules/.bin/update-app-ng-deps
    npm i
    
    # Webpack Upgrade
    npm i nativescript-dev-webpack --save-dev
    ./node_modules/.bin/update-ns-webpack --deps --configs
    

    For Windows users, user the Windows path separators and the .cmd file extension.

    .\node_modules\.bin\ns-upgrade-tsconfig.cmd
    .\node_modules\.bin\update-app-ng-deps.cmd
    .\node_modules\.bin\update-ns-webpack.cmd --deps --configs
    

    I'm also using NativeScript UI. Here are the commands I had to run.

    tns plugin remove nativescript-ui-sidedrawer
    tns plugin add nativescript-ui-sidedrawer
    
    tns plugin remove nativescript-ui-dataform
    tns plugin add nativescript-ui-dataform
    
    ...
    

    Confirm you are using the latest version by running tns info.

    tns info
    

    You can now use the Preview app. Run the command.

    tns preview