Updating to nodejs 4x MEAN stack - node.js

So I've been using node v 0.10x and 0.12x for dev and prod environments.
Now we need to upgrade to v4x and as I'm doing so, I'm finding that is not so easy, gcc compiler issues, deprecated libs...
Here are some of the messages I'm getting
I was able to overcome the c++11 problems
Updating to Node.js 4
Node on old distributions
Now what I would like is to have the builds as clean as possible,
as well as to know what is the impact of having this deprecated libraries in the project in the short/long term,
is it possible to completely get rid of them? if so is there a kind of best practices approach for this?
For instance I updated lodash#1.0.2 to version 4 in the main package.json file just to find/get more deprecated libraries like a nested deprecated libraries, so is it really possible to get rid of this deprecated libraries?

If you are migrating from v0.1 to v.0.2, you need create a node link between the local and the global modules.
About the warnings,
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents#1.0.8
Don-t be afraid about the after update all the packages, some packages are marked as deprecated but the doesn't have any update available, then if you tried update them, don't worry, that doesn't affect your project.
And releated with the last of your issues:
UNMET PEER DEPENDENCY kerberos#~0.0
First one you need update your kerberos development package:
apt-get install libkrb5-dev
And running the command:
npm install --save kerberos mongod
If that doesn't fix your issue, you could try in a manual way intall all the packages with:
git clone https://github.com/christkv/kerberos.git
cd kerberos
npm install
npm install -g node-gyp
cd ~/JesusTheProject
npm install mongodb --save
npm --loglevel verbose install mongodb

Related

Is it necessay to update npm to update node?

I am new to npm and node so pardon if my question is silly, but is it necessary to update npm to its latest version if i want to update Node.js to its latest version? I read the npm wikipedia page and it says npm is a package manager for Node.js. Also, does npm provide a runtime environment for Node appications to work?
Node.js is the runtime (using the V8 JavaScript engine). Yes, npm is a package manager that helps include dependencies in the program, but it is not the only one. There are others like yarn, so npm is not essential to Node.js. There are several upgrade methods to choose from, using all the same installation methods typically available on operating systems. npm does not offer Node.js upgrades directly; options include node version manager and the npm-installable module n:
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
None of the methods mention an npm update, though it is a good idea to keep npm current for security. If a given upgrade method does require you to have a certain version of some manager or installer, you will get a message about it when trying to upgrade.

how to update warn deprecated

I'm trying to learn node and npm, using express for a little project.
When i install it, i got
npm WARN deprecated core-js#2.6.10: core-js#<3.0 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js#3.
I understood that if everything works, it's not necessary to update everything, but i'm trying to learn and go the extra, unnecessary, mile.
How can i update only core-js?
npm install core-js#^3
will update it adding it to the dependencies in package.json.
Is this the right way to do it?
Or it's better to update the parent package that use it? If so, how can i understand which is the package that need an update and how to update it?
Or is there a way to update only the modules listed in package-lock.json.
Thanks.
You provided one way to update a package. However, there are a few more.
To update a global package, you could run:
npm update -g <package_name>
To update a package that's in your package.json (i.e., local to your project), run:
npm update <package_name>
You could also see what outdated package are there as follows:
npm outdated
You could again add -g option to check outdated global packages.
Sources: https://docs.npmjs.com/updating-packages-downloaded-from-the-registry
Also: man npm may help (in Linux).
To update to a new major version all the packages, install the npm-check-updates package globally:
npm install -g npm-check-updates
this will upgrade all the version hints in the package.json file, to dependencies and devDependencies, so npm can install the new major version.
You are now ready to run the update:
npm update
or npm install

Multiple versions of same peerDependency required

When I run npm i on my current react project, I get the following warning regarding react peerDependency:
npm WARN react-tap-event-plugin#3.0.3 requires a peer of react#^16.0.0-0 < 16.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN react-paginate#4.4.4 requires a peer of react#^15.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN formsy-react#0.19.5 requires a peer of react#^0.14.0 || ^15.0.0 but none is installed. You must install peer dependencies yourself.
While in my package.json, I am using latest version of react:
"react": "^16.7.0"
I am new to node and npm. I would like to know what is the good practice for installing npm peerDependencies:
1.) Can the warnings for lower versions be ignored if updated version is already specified in package.json.
2.) As per
https://lexi-lambda.github.io/blog/2016/08/24/understanding-the-npm-dependency-model/
and
https://github.com/npm/npm/issues/6565
npm provides dependency isolation and peerDepencies needs to be manually installed, so should I install all 3 versions of react but I fear that will break the import statements.
3.) If none of the above two, which version should I use in package.json.
P.S. there are many more dependencies in my package.json which might require latest version also.
Taking Danyal's answer further, you can upgrade formsy-react and remove react-tap-event-plugin:
Update formsy-react to latest version: (1.1.5 at time of writing), the latest version of this package supports react ^16.
react-tap-event-plugin supports react version upto version 16.4. You have a few options here:
Downgrade react: downgrading to 16.4 will remove all the warnings, but will restrict your ability to upgrade in the future
Remove react-tap-event-plugin: According to the documentation https://www.npmjs.com/package/react-tap-event-plugin. This module is actually deprecated thanks to fixes made to later browsers. Check the blog post for info.
Fork react-tap-event-plugin: I wouldn't do this myself, but you could fork the plugin and publish it yourself with the updated react peerDependency.
A peer dependency means that a package is applicable to used with a particular version of the dependency & wouldn't work as intended if you exceed the specified version.
In your case react-tap-event-plugin#3.0.3 requires a version of React less than 16.4.0, react-paginate#4.4.4 requires any version of React 15 and the same for formsy-react#0.19.5.
You would need to downgrade from React 16.7.0, but that can break your application if you are using 16.7.0 features, or you could remove the packages and use another one or write the package's logic from start yourself.
Tip: always make sure to read package dependencies on npm website before actually considering to use a package for your project.

Google polymer starter kit WARN when npm install

When I download "Intermediate - Advanced users" version of polymer starter kit from github here and on the 4th step of these instructions here I always getting these WARNs:
$ sudo npm install
npm WARN deprecated gulp-minify-css#1.2.4: Please use gulp-clean-css
npm WARN deprecated graceful-fs#3.0.8: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs#^4.0.0 as soon as possible.
npm WARN engine launchpad#0.5.1: wanted: {"node":"^0.12"} (current: {"node":"4.4.2","npm":"2.15.0"})
npm WARN deprecated lodash#1.0.2: lodash#<3.0.0 is no longer maintained. Upgrade to lodash#^4.0.0.
npm WARN optional dep failed, continuing fsevents#1.0.11
npm WARN deprecated graceful-fs#1.2.3: graceful-fs version 3 and before will fail on newer node releases. Please update to graceful-fs#^4.0.0 as soon as possible.
npm WARN deprecated jade#0.26.3: Jade has been renamed to pug, please install the latest version of pug instead of jade
No matter what OS I'm using: tried both Ubuntu and Windows (git bash).
I have npm, bower, gulp installed globally but there's always those WARNs.
I think that maybe it's a dependencies problem or it's because of some code in some of polymer starter kit files, but I'm not a pro developer, so I can't find what is causing the problem
It's all seems to work though when I deploy the project, but I'm new to web dev and not sure if I have to just close my eyes on these WARNs
Nothing to worry about with those warnings. Those come from the npm packages that are set as dependencies in the package.json file. When you run npm install it will install all packages set in the package.json. Every single package has their own package.json that also has some dependenices. Each package install their own needed version of that package and sometimes they use older versions of those packages. Only way to get rid of those warnings would be to get the package creators to update their packages.
Only package that you can update yourself is the gulp-minify-css. You can uninstall that package npm remove gulp-minify-css --save-dev and install the newer non-deprecated version gulp-clean-css. npm install gulp-clean-css --save-dev. If you do that you need to update the gulpfile.js for the project to use the new package.
Find the styleTask for the starter-kit in the gulpfile.js:
var styleTask = function(stylesPath, srcs) {
return gulp.src(srcs.map(function(src) {
return path.join('app', stylesPath, src);
}))
.pipe($.changed(stylesPath, {extension: '.css'}))
.pipe($.autoprefixer(AUTOPREFIXER_BROWSERS))
.pipe(gulp.dest('.tmp/' + stylesPath))
.pipe($.minifyCss())
.pipe(gulp.dest(dist(stylesPath)))
.pipe($.size({title: stylesPath}));
};
and change the .pipe($.minifyCss()) row to be .pipe($.cleanCss({compatibility: 'ie10'}))
Now you have managed to update the starter-kit to use newer non-deprecated package.
Many packages in the npm package manager have some deprecated packages or cause other warnings while installing but most of the time there is no need to worry.
No need to worry about those warnings in this case. They shouldn't cause the problems that you allude to. I verified the PSK guide you mentioned (the page completely appears and functions without error in Chrome Version 49.0.2623.112 on OSX El Capitan).
npm displays deprecation warnings when a dependency being installed has been deprecated by the dependency's package owner/maintainer usually in favor of another package/version that has significant improvements. Packages can be deprecated/undeprecated at will and long after your app has been deployed.
For example, in January, you release an app that depends on gulp-minify-css#1.2.4. The owner of gulp-minify-css no longer has time to maintain the package, so he decides in March to deprecate it in favor of the actively maintained gulp-clean-css. Now, users who npm install your app (which also installs gulp-minify-css) see this deprecation warning, but your app still functions normally. The deprecation does not invalidate your app or cause errors.
While normally one might try to upgrade the dependencies to remove the warnings, that is not recommended for PSK due to package incompatibilities as recently discovered in a pull request:
So I just took this for a spin and I ran into some issues :( although
the current gulp plugins are deprecated they are working for the
community! This PR represents a "high risk" change, that we have found
to be breaking in several odd ways. For that reason I am going to
close this PR for now. That said let's revisit this PR in a few months
and see if things have stabilized more.

NPM warn message about deprecated package

I am installing a module globally
$ npm install -g X
and NPM says
"npm WARN deprecated lodash#1.0.2: lodash#<3.0.0 is no longer
maintained. Upgrade to lodash#^4.0.0"
how can I find out which module has an dependency on this old version of lodash?
The warning message from NPM doesn't seem to give me any clue which module references this old version (I believe that the module X does not have a direct dependency on this old version of lodash.).
I got an answer for the similar question: https://stackoverflow.com/a/36335866/1115187
Briefly:
npm outdated --depth=3
This command will analyze installed NPM-packages and their versions. The report will contain:
package name
latest version
current version
dependency path (down to depth level)
Hope, this information could help you to gather info about outdated packages.
Next step - get in touch with maintainers of the appropriate package, and ask them to update the package (maybe, you would like to send a pull request).
UPD: npm-check
There is a great npm package: npm-check, that allows checking outdated dependencies. Probably
My favorite feature: Interactive Update — run npm-check -u in the project folder. An interactive menu shows all required information about dependencies in the current folder and allows to update all dependencies in 3 seconds.
npm la <package-name>
also works, and will give you the most details about the dependency graph of a dependency.
npm ls <package-name>, does something similar but gives you less details
Use npm list. It will print out all of the packages your module depends on as well as your dependencies dependencies and so forth. Maybe redirect output to a file or grep it so you can search it more easily.
use this
sudo npm install --unsafe-perm -g expo-cli
You could search through all the package.json files under node_modules and see which ones are dependent on lodash 1.0.2.
For deprecated files you should use the "npm i [package]" syntax, in this case you should use: npm i X and it will fetch all necessary packages, including deprecated ones, but which are required for your installation.
Npm documentation link: https://docs.npmjs.com/using-deprecated-packages

Resources