Make Dokku stay on major version - dokku

On my package.json file I have the following below. As expected it is installing version 16.x but I would like it to only install the latest 12.x. Is there a way to setup the app to only do that?
"engines": {
"node": ">=12.19.0"
},

If I understand your question correctly, you should be able to just use 12.x in your package.json. (Heroku Docs/NPM Docs)
"engines": {
"node": "12.x"
}
You can use NPM's semver syntax to define supported versions. If you only want versions greater than 12.19.0 but still within 12.x, you can use ^12.19.0.

Related

Yarn installing too many libraries

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...

Cloud Functions for Firebase Async Await style

Looks like Cloud Functions does not support Async-Await notation. Is there a way I could use Babel until they do or is it recommended to use promises?
My current function that sits on Node is like so:
exports.getToken = async (req, res) => {
//1. Generate token from Braintree
const result = await gateway.clientToken.generate();
//2. Return the client token
res.json(result.clientToken);
};
Cloud Functions runs the LTS version of node.js, which according to the documentation is 6.14.0 at this moment in time. node 6.x supports EcmaScript 6, which does not include async/await.
However, you can write your code in TypeScript and have that transpiled down to ES5/ES6, which will effectively convert the use of async/await into promises. A web search suggests that perhaps this plugin can be used to help Babel with similar transpiling.
It's worth noting that the Firebase CLI now allow you to initialize a new Cloud Functions project with native TypeScript support, which is what the Firebase team is currently recommending to developers.
If you don't want to use TypeScript, you can now also choose node 8 (which is currently in beta, and does support async/await for plain JavaScript) as a deployment target. You can follow the documentation to edit your package.json to indicates that your functions should be deployed to node 8.
Now you can use Node.js version 8 by adding this in your functions/package.json:
"engines": {
"node": "8"
}
Example: https://github.com/firebase/functions-samples/blob/Node-8/authenticated-json-api/functions/package.json
Instead of transpile TypeScript, I have transpiled my javascript after follow this very nice post and take a look at this repository
Basically you can do:
npm install -g #babel/cli #babel/core #babel/preset-env
UPDATE:
I'm having troubles with version "7.0.0-beta.51" of babel. "7.0.0-beta.44" still ok.
Switch to stable version 6
npm install --save-dev babel-cli babel-preset-env
Create the file .babelrc inside your project folder
{
"presets": [
["#babel/env", {
"targets": {
"node": "6.11.5"
}
}]
]
}
Move your "functions" folder to "firebaseFunctions" folder and then run
babel firebaseFunctions --out-dir functions --copy-files --ignore firebaseFunctions/node_modules
Or run this command for each files you want to transpile
babel originalfile.js --out-file transpiledfile.js
The above solutions didn't work for me alone. I had to update to the latest firebase tools:
npm update -g firebase-tools
and then update my package.json with adding:
"engines": {"node": "8"}
and everything worked fine with async/await.
Credits to this blog https://howtofirebase.com/cloud-functions-migrating-to-node-8-9640731a8acc
In your functions/.eslintrc.json file set as 'ecmaVersion': 2017
this will remove eslint syntax error
"parserOptions": {
"ecmaVersion": 2017
},
In your functions/package.json file set node version to 8 by adding below
"engines": {
"node": "8"
},
this will update the cloud node version to 8 default node version is 6
as #adam said, solved my problem to reinstall/upgrade the global firebase package
the difference is in my case was using NVM (node version manager).
Somehow, my default node(v13.x) had the firebase-tools but i didnt installed globally at project node (v10/8)
so first:
nvm use 10
then:
npm i -g firebase-tools
reinstalling at correct node version got my async functions working properly.

How to update angular2 version in meteor project? [duplicate]

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

dotnet run - looking for Microsoft.NETCore.App 1.1.0 (not preview) - I never refer to it

I have a fairly in-depth project setup with 10-20 libraries, and I'm trying to build an executable which uses them.
I have .NET Core 1.1.0 preview1 installed. With new projects, everything works fine. dotnet restore and dotnet build also work fine for this project, but somewhere along the line, something is wrong, and it will not run.
dotnet run yields:
The specified framework 'Microsoft.NETCore.App', version '1.1.0' was not found.
- Check application dependencies and target a framework version installed at:
C:\Program Files\dotnet\shared\Microsoft.NETCore.App
- The following versions are installed:
1.0.1
1.1.0-preview1-001100-00
- Alternatively, install the framework version '1.1.0'.
My library projects have:
"frameworks": {
"netstandard1.6": {
"dependencies": {
"NETStandard.Library": "1.6.1-preview1-*"
}
}
}
My executable project has:
"frameworks": {
"netcoreapp1.1": {
"dependencies": {
"Microsoft.NETCore.App": {
"version": "1.1.0-preview1-*",
"type": "platform"
}
},
"imports": [ "dnxcore50", "portable-net45+win8" ]
}
}
It does also reference another project which is set up with an entry point, whose frameworks section is identical, minus the imports section.
I've also updated any EF Core and ASP.NET Core references to their preview1-* versions, though I am using plenty of other dependencies too (which weren't versioned in the same way).
So, as you can see, I have 1.1.0-preview1-001100-00 installed, am not referencing 1.1.0 anywhere, and yet receiving this message looking for it.
What could be causing this, and/or how can I track it down? I've tried scouring project.json.lock files, but can't see any references to 1.1.0 there, with the exception of an entry for Microsoft.NETCore.App/1.1.0 under libraries and again under the ".NETCoreApp,Version=v1.1" part of targets.
Wildcards aren't appropriate and don't work for this kind of platform dependency.
It's necessary to use
"version": "1.1.0-preview1-001100-00"
and not
"version": "1.1.0-preview1-*"
I have faced with the same problem deploying on Heroku instance. In may case during deployment the latest build is used (https://github.com/sass/node-sass/releases/download/v3.10.1/linux-x64-46_binding.node).
As a workaround it works if change
"Microsoft.NETCore.App": {
"version": "1.1.0-preview1-*",
to
"Microsoft.NETCore.App": {
"version": "1.1.0",
but on the other hand, it stops to work on local machine in this case...

How do I use smart.json to tell meteorite to use a stable version of meteor?

As far as I can tell, the point of meteorite is to simplify dealing with which versions of plugins and branch of meteor your project needs. But I don't want to follow the churn on a branch of meteor; I want to use a stable version. It seems as if this should be possible. How do I do it?
You can specify alternate branches and forks respectively:
{
meteor: {
"branch": "devel",
"git": "https://github.com/meteor/meteor.git"
}
}
Per the documentation:
The meteor specification is not required. Meteor's public repo checked out to the master branch is the default. You can specify meteor.branch and meteor.git to use alternate branches and forks respectively.
To use a stable version, simply omit the meteor section from the smart.json file altogether and you'll use the most recent, stable version.
Use tag to choose a particular Meteor version:
"meteor": {
"git": "https://github.com/meteor/meteor.git",
"tag": "release/0.6.3.1"
},
(See --tag in http://oortcloud.github.com/meteorite/)

Resources