Node.js 9 vs npm

Ever since the www/node package was updated to 9.x, the www/npm package won't work with it. Please see the error below:

Code:
WARNING: You are likely using a version of node-tar or npm that is incompatible with this version of Node.js.
Please use either the version of npm that is bundled with Node.js, or a version of npm (> 5.5.1 or < 5.4.0) or node-tar (> 4.0.1) that is compatible with Node.js 9 and above.
/usr/local/bin/node[48876]: ../src/node_zlib.cc:437:static void node::(anonymous namespace)::ZCtx::Init(const FunctionCallbackInfo<v8::Value> &): Assertion `args.Length() == 7 && "init(windowBits, level, memLevel, strategy, writeResult, writeCallback," " dictionary)"' failed.
 1: node::Abort(void) [/usr/local/bin/node]
 2: node::Assert(char const* const[4]*) [/usr/local/bin/node]
 3: _ZNSt3__16vectorIPN4node14SigintWatchdogENS_9allocatorIS3_EEE21__push_back_slow_pathIRKS3_EEvOT_ [/usr/local/bin/node]
 4: v8::internal::FunctionCallbackArguments::Call(void(*)(v8::FunctionCallbackInfo<v8::Value> const&)) [/usr/local/bin/node]
 5: v8::internal::Isolate*<v8::internal::Object> v8::internal::Builtins::InvokeApiFunction(v8::internal::Isolate*, bool, v8::internal::Handle<v8::internal::HeapObject>(int, v8::internal::Object*, v8::internal::HeapObject) [/usr/local/bin/node]
 6: v8::internal::Builtin_HandleApiCall(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]

This is because www/npm has dependencies towards www/node, www/node is at 9.x but www/npm is at 5.4.2, which is incompatible with Node.js 9. Furthermore, there appears to be no mechanism in place to use the LTS version of Node.js (currently 8.x) with www/npm. You can install www/node8 without a hitch. Once you're installing www/npm, it depends on www/node instead of www/node8 and will uninstall the latter. This leaves you in a catch-22 situation where www/node does not work with www/npm and www/npm does not allow www/node8 to be installed.

As I am using binary packages, compiling www/npm with Node 8 bindings is not feasible, as it would leave my system in a state that I would either have to compile everything from source all of the time, lock the packages and never be able to install bugfixes or have every update constantly update www/node while having a non-functional www/npm. This appears to be broken as of now.

In any case, it should be possible to easily use the LTS version instead of the latest one. I think the logic is upside down here: LTS should be the default with an optional Node 9 installation.

Any suggestions how to resolve this or is this a bug that should be reported to the package maintainer?
 
I had the same error with npm-5.4.2_2 and node-9.2.0, so I used npm from node source:
svnlite export https://github.com/nodejs/node/trunk/deps/npm && cd npm && node bin/npm-cli.js install -gf
 
Still does not work.
Code:
# npm -v
5.4.2
# node -v
v9.2.0
# pkg info npm
npm-5.4.2_4
Name           : npm
Version        : 5.4.2_4
Installed on   : Fri Dec  8 08:25:14 2017 UTC
Origin         : www/npm
Architecture   : FreeBSD:11:*
Prefix         : /usr/local
Categories     : www
Licenses       : MIT
Maintainer     : sunpoet@FreeBSD.org
WWW            : https://www.npmjs.com/package/npm
Comment        : Node package manager
Options        :
        NODE           : on
        NODE4          : off
        NODE6          : off
        NODE8          : off
 
Still does not work.
Code:
# npm -v
5.4.2
# node -v
v9.2.0
# pkg info npm
npm-5.4.2_4
Name           : npm
Version        : 5.4.2_4
Installed on   : Fri Dec  8 08:25:14 2017 UTC
Origin         : www/npm
Architecture   : FreeBSD:11:*
Prefix         : /usr/local
Categories     : www
Licenses       : MIT
Maintainer     : sunpoet@FreeBSD.org
WWW            : https://www.npmjs.com/package/npm
Comment        : Node package manager
Options        :
        NODE           : on
        NODE4          : off
        NODE6          : off
        NODE8          : off

See this thread on FreeBSD's bugzilla.
 
Looking closer, I see there's something weird going on with the version.

Code:
# pkg info npm
npm-5.6.0
Name           : npm
Version        : 5.6.0
Installed on   : Wed Dec 13 15:07:14 2017 CET
Origin         : www/npm
Architecture   : FreeBSD:10:*
Prefix         : /usr/local
Categories     : www
Licenses       : MIT
Maintainer     : sunpoet@FreeBSD.org
WWW            : https://www.npmjs.com/package/npm
Comment        : Node package manager
Options        :
        NODE           : on
        NODE4          : off
        NODE6          : off
        NODE8          : off
Annotations    :
        cpe            : cpe:2.3:a:npmjs:node_packaged_modules:5.6.0:::::freebsd10:x64
        repo_type      : binary
        repository     : <our local repository>
Flat size      : 20.2MiB
Description    :
npm is a package manager for node. You can use it to install and publish your
node programs. It manages dependencies and does other cool stuff.

WWW: https://www.npmjs.com/package/npm
WWW: https://github.com/npm/npm
Note the 5.6.0 version being indicated.
Yet:
Code:
# node --version
v9.2.0
# npm --version
5.5.1
5.5.1 was the previously released version according to the Github page.
 
Back
Top