Recently I started Angular 2 tutorial at https://angular.io/docs/ts/latest/tutorial/.
and left off with Angular 2 beta 8.
Now I resumed the tutorial and latest beta is beta 14.
If I simply do npm update a few modules (preloaded with the tutorial) are updated but not Angular2 (I can see that with npm ls).
If I do npm update angular 2 or npm update angular2#2.0.0beta.14 it just does nothing either.
The command npm update -D && npm update -S will update all packages inside package.json to their latest version, according to their defined version range. You can read more about it here.
If you want to update Angular from a version prior to 2.0.0-rc.1, then you'll need to manually edit package.json, as Angular was split into several npm modules. Without this, as angular2 package points to 2.0.0-beta.21, you'll never get to use the latest version of Angular.
A list with some of the most common modules that you'll need to get started can be found in the quickstart repository.
Notes:
A cool way to stay up to date with your packages' latest version is to use npm outdated which shows you all outdated packages together with their wanted and latest version.
The reason why we need to chain two commands, npm update -D and npm update -S is to overcome this bug until it's fixed.
Another nice package which I used for migrating form a beta version of Angular2 to Angular2 2.0.0 final is npm-check-updates
It shows the latest available version of all packages specified within your package.json. In contrast to npm outdated it is also capable to edit your package.json, enabling you to do a npm upgrade later.
Install
sudo npm install -g npm-check-updates
Usage
ncufor display
ncu -u for re-writing your package.json
Upgrade to latest Angular 5
Angular Dep packages:
npm install #angular/{animations,common,compiler,core,forms,http,platform-browser,platform-browser-dynamic,router}#latest --save
Other packages that are installed by the angular cli
npm install --save core-js#latest rxjs#latest zone.js#latest
Angular Dev packages:
npm install --save-dev #angular/{compiler-cli,cli,language-service}#latest
Types Dev packages:
npm install --save-dev #types/{jasmine,jasminewd2,node}#latest
Other packages that are installed as dev dev by the angular cli:
npm install --save-dev codelyzer#latest jasmine-core#latest jasmine-spec-reporter#latest karma#latest karma-chrome-launcher#latest karma-cli#latest karma-coverage-istanbul-reporter#latest karma-jasmine#latest karma-jasmine-html-reporter#latest protractor#latest ts-node#latest tslint#latest
Install the latest supported version used by the Angular cli (don't do #latest):
npm install --save-dev typescript#2.4.2
Rename file angular-cli.json to .angular-cli.json and update the content:
{
"$schema": "./node_modules/#angular/cli/lib/config/schema.json",
"project": {
"name": "project3-example"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.app.json",
"testTsconfig": "tsconfig.spec.json",
"prefix": "app",
"styles": [
"styles.css"
],
"scripts": [],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"project": "src/tsconfig.app.json",
"exclude": "**/node_modules/**"
},
{
"project": "src/tsconfig.spec.json",
"exclude": "**/node_modules/**"
},
{
"project": "e2e/tsconfig.e2e.json",
"exclude": "**/node_modules/**"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}
UPDATE:
Starting from CLI v6 you can just run ng update in order to get your dependencies updated automatically to a new version.
With ng update sometimes you might want to add --force flag.
If you do so make sure that the version of typescript you got
installed this way is supported by your current angular version,
otherwise you might need to downgrade the typescript version.
Also checkout this guide Updating your Angular projects
For bash users only
If you are on are on Mac/Linux or running bash on Windows(that wont work in default Windows CMD) you can run that oneliner:
npm install #angular/{animations,common,compiler,core,forms,http,platform-browser,platform-browser-dynamic,router,compiler-cli}#4.4.5 --save
yarn add #angular/{animations,common,compiler,core,forms,http,platform-browser,platform-browser-dynamic,router,compiler-cli}#4.4.5
Just specify version you wan't e.g #4.4.5 or put #latest to get the latest
Check your package.json just to
make sure you are updating all #angular/* packages that you app is relying on
To see exact #angular version in your project run:
npm ls #angular/compiler or yarn list #angular/compiler
To check the latest stable #angular version available on npm run:
npm show #angular/compiler version
Official npm page suggest a structured method to update angular version for both global and local scenarios.
1.First of all, you need to uninstall the current angular from your
system.
npm uninstall -g angular-cli
npm uninstall --save-dev angular-cli
npm uninstall -g #angular/cli
2.Clean up the cache
npm cache clean
EDIT
As pointed out by #candidj
npm cache clean is renamed as npm cache verify from npm 5 onwards
3.Install angular globally
npm install -g #angular/cli#latest
4.Local project setup if you have one
rm -rf node_modules
npm install --save-dev #angular/cli#latest
npm install
Please check the same down on the link below:
https://www.npmjs.com/package/#angular/cli#updating-angular-cli
This will solve the problem.
Alternative approach using npm-upgrade:
npm i -g npm-upgrade
Go to your project folder
npm-upgrade check
It will ask you if you wish to upgrade the package, select Yes
That's simple
If you want to install/upgrade all packages to the latest version and you are running windows you can use this in powershell.exe:
foreach($package in #("animations","common","compiler","core","forms","http","platform-browser","platform-browser-dynamic","router")) {
npm install #angular/$package#latest -E
}
If you also use the cli, you can do this:
foreach($package in #('animations','common','compiler','core','forms','http','platform-browser','platform-browser-dynamic','router', 'cli','compiler-cli')){
iex "npm install #angular/$package#latest -E $(If($('cli','compiler-cli').Contains($package)){'-D'})";
}
This will save the packages exact (-E), and the cli packages in devDependencies (-D)
Just start here:
https://update.angular.io
Select the version you're using and it will give you a step by step guide.
I recommend choosing 'Advanced' to see all steps. Complexity is a relative concept - and I don't know whose stupid idea this feature was, but if you select 'Basic' it won't show you all steps needed and you may miss something important that your otherwise 'Basic' application is using.
As of version 6 there is a new Angular CLI command ng update which intelligently goes through your dependencies and performs checks to make sure you're updating the right things :-)
The steps will outline how to use it :-)
npm uninstall --save-dev angular-cli
npm install --save-dev #angular/cli#latest
ng update #angular/cli
ng update #angular/core --force
ng update #angular/material or npm i #angular/cdk#6
#angular/material#6 --save
npm install typescript#'>=2.7.0 <2.8.0'
Best way to do is use the extension(pflannery.vscode-versionlens) in vscode.
this checks for all satisfy and checks for best fit.
i had lot of issues with updating and keeping my app functioining unitll i let verbose lense did the check and then i run
npm i
to install newly suggested dependencies.
If you are looking like me for just updating your project to the latest these is what works form me since Angular 6:
Open the console on your project folder: If you type: ng update then you will get the below message:
We analyzed your package.json, there are some packages to update:
Name Version Command to update
--------------------------------------------------------------------------------
#angular/cli 7.0.7 -> 7.2.2 ng update #angular/cli
#angular/core 7.0.4 -> 7.2.1 ng update #angular/core
There might be additional packages that are outdated.
Run "ng update --all" to try to update all at the same time.
So I usually go straight and do:
ng update --all
Finally you can check your new version:
ng version
Angular CLI: 7.2.2
Node: 8.12.0
OS: win32 x64
Angular: 7.2.1
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
#angular-devkit/architect 0.12.2
#angular-devkit/build-angular 0.12.2
#angular-devkit/build-optimizer 0.12.2
#angular-devkit/build-webpack 0.12.2
#angular-devkit/core 7.2.2
#angular-devkit/schematics 7.2.2
#angular/cli 7.2.2
#ngtools/webpack 7.2.2
#schematics/angular 7.2.2
#schematics/update 0.12.2
rxjs 6.3.3
typescript 3.2.4
webpack 4.28.4
Related
I am currently stuck at the Encore/Webpack installation. I followed the steps at symfony.com. But when continuing to the simple example I got stuck at running yarn encore dev. I get the error: "Command "encore" not found". I also have an error when running symfony server:start after installing Encore and navigating to a view:
An exception has been thrown during the rendering of a template ("Could not find the entrypoints file from Webpack: the file "path/entrypoints.json" does not exist.").
As far as I know the entrypoints.json should have been autogenerated. I have Yarn 1.22.10 and NodeJS 14.16.1.
What I have done
I executed the commands composer require symfony/webpack-encore-bundle
and yarn install
I looked at StackOveflow questions 'error Command "encore" not found.' when running 'yarn run encore' in Symfony4, webpack encore dev-server not found /, Error Command "encore" not found. (separate backend webpack), Can't run encore dev
I executed the command composer require webpack
I noticed my package.json doesn't have a scripts object where the command encore dev is supposed to be living. I watched a YouTube video and followed it (https://youtu.be/Fs_4FMoSO90). That's why I know this. I wonder why I don't have it. Below is the package.json from the video. My package.json only has the dev dependency Bootstrap.
Executed npm install
Package.json from video:
{
"devDependencies": {
"#symfony/webpack-encore": "^0.31.0",
"core-js": "^3.0.0",
"regenerator-runtime": "^0.13.2",
"webpack-notifier": "^1.6.0"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress"
}
}
My package.json:
{
"devDependencies": {
"bootstrap": "^5.0.0"
}
}
I removed the package.json, package-lock.json and executed yarn install again and it installed some packages. I didn't need NPM. I already got Bootstrap from my Yarn.lock (that's the only thing in there). I still have both errors though.
After Yivi's advice I executed composer req webpack, yarn install and yarn encore dev. The difference is that I executed composer require symfony/webpack-encore-bundle which is what is mentioned on the installation page on the symfony website. The yarn encore dev command tries to run webpack now, but I get the following error: Error: Encore.enableStimulusBridge is not a recognized property or method. webpack.config.js:26 Object.<anonymous>
webpack.config.js line 26
// enables the Symfony UX Stimulus bridge (used in assets/bootstrap.js)
.enableStimulusBridge('./assets/controllers.json')
Your advice worked msg. I installed the recipes with composer recipes:install symfony/webpack-encore-bundle --force -v and now yarn encore dev compiles webpack successfully. I now also know that I accidentally kept the package.json from the video in my project which explains why my error changed from Command encore not found to Error: Encore.enableStimulusBridge is not a recognized property or method. webpack.config.js:26 Object.<anonymous>
So I have a Typescript project called backend with a depedency like such in its package.json:
"dependencies": {
"#the-couple-game/helpers": "^1.0.0",
}
And helpers (also Typescript) is in another folder with its package.json like such:
{
"name": "#the-couple-game/helpers",
}
So running lerna bootstrap should link the two and install #the-couple-game/helpers in backend's node_modules which it does locally.
However, doing the same (with --no-ci because I don't want npm ci) using Codebuild using the below buildspec.yml does not add a #the-couple-game/helpers in backend's node_modules. So if I run backend's transpiled index.js it would complain about the missing module.
version: 0.1
phases:
install:
commands:
- npm install -g lerna
pre_build:
commands:
- lerna bootstrap --no-ci --concurrency 4
build:
commands:
- lerna run build --concurrency 4
artifacts:
files:
- "**/*"
For now, I have to resort to manually doing a lerna bootstrap after deployment to CodeDeploy (using a script called from appspec.yml) so it installs the missing module but shouldn't Codebuild have covered that part?
Thanks.
So it turns out AWS CodePipeline doesn't support symlinks in source (Codebuild in my case). Reference
So after deployment, I'll have to lerna link using a shell script to create the links which is not an expensive job for my micro ec2 instance to do.
I am working on a Symfony project and use Yarn to manage all my libraries. So, I have the list of the libraries in my package.json
package.json
{
"name": project,
"version": "1.0.0",
"dependencies": {
[10 libraries ...]
}
"engines": {
"yarn": ">= 1.0.0"
}
}
I am calling for 10 dependencies in my package.json and in my node_mdules files, I have more than 180 libraries installed...
I don't understand why it installs so many files. Moreover, those files are not additionnal libraries for the ones I use
I am using Symfony 3.4 and Yarn 1.12.3
I've decided to reset Yarn by reinstalling it, removing all the dependencies installed locally and saving the package.json file.
Then, I've just reinstalled it and everything is ok. I had to look on the yarn.lock file, everything was installed from there, this was causing the problem.
Hope this may help someone...
I am creating a Meteor/Angular/Ionic App (meteor create MyApp), and when running (meteor run ios), a WARNING is thrown which suggests that Cordova plugin splashscreen should be updated from 3.2.1 to 4.0.0 :
" WARNING: Attempting to install plugin
cordova-plugin-splashscreen#3.2.1, but it should have a minimum
version of 4.0.0 to ensure compatibility with the current platform
versions. Installing the minimum version for convenience, but you
should adjust your dependencies. "
I understand there are suggestions to reinstall the cordova plugin using (which I have done but the warning still remains):
meteor add cordova:cordova-plugin-meteor-webapp#https://github.com/meteor/cordova-plugin-meteor-webapp.git#8bf95eed3f313299fc2de33658866278eea2cdc5
meteor add cordova:cordova-plugin-meteor-webapp#1.4.1
rm -rf .meteor/local/cordova-build
I checked my app project directory and realised that (prior to any updates), I already have Cordova 4.0.0 package installed in ../.meteor/local/cordova-build/plugins/cordova-plugin-splashscreen/package.json
{
"name": "cordova-plugin-splashscreen",
"version": "4.0.0",
"description": "Cordova Splashscreen Plugin",
"cordova": {
"id": "cordova-plugin-splashscreen",
"platforms": [
"android",
"amazon-fireos",
"ubuntu",
"ios",
"blackberry10",
"wp8",
"windows8",
"windows",
"tizen"
]
},
So my current guess is Meteor has a config file somewhere that is NOT pointing to the Cordova splashscreen version 4.0.0 that exists.
Can any experts help me with my question:
Is my guess that I should modify a Config file to point to the right
Cordova version correct?
Where can I find this file in my Meteor App folder?
I was following yeoman tutorial http://yeoman.io/codelab/prepare-production.html and everything worked fine until I tried to launch my project with "grunt" command then I got the following error:
Running "autoprefixer:dist" (autoprefixer) taskAutoprefixer's process() method is deprecated and will removed in next major release. Use postcss([autoprefixer]).process() insteadFile .tmp/styles/main.css created.
jit-grunt: Plugin for the "ngtemplates" task not found.If you have installed the plugin already, please setting the static mapping.See https://github.com/shootaroo/jit-grunt#static-mappings
Warning: Task "ngtemplates" failed. Use --force to continue.
Aborted due to warnings.
I use Linux Mint 17
A workaround was posted at the generator-angular github. Try modifying your Gruntfile.js to make the jit-grunt block look like this:
// Automatically load required Grunt tasks
require('jit-grunt')(grunt, {
useminPrepare: 'grunt-usemin',
ngtemplates: 'grunt-angular-templates',
cdnify: 'grunt-google-cdn'
});
This is a issue for grunt-autoprefixer which is deprecated.
I am guessing, you installed a old version of generator-angular and current version of grunt which is written in the tutorial with following commands.
npm install --global yo bower grunt-cli
npm install --global generator-angular#0.11.1
It is better to install the current version of generator-angular. Just run this and start over again.
npm install -g generator-angular