Unable to load Node backend for Tensorflow (TypeError: Cannot read property 'nonMaxSuppressionV3Impl' of undefined) - tfjs-node

I'm trying to use face-api.js facial recognition functions, which would run a lot faster with an installed Node backend. I've installed the backends with npm as below:
$ node -v
v14.1.0
$ npm list #tensorflow/tfjs-node
appname#0.1.0 /Users/akoi/Dev/bwr
└── #tensorflow/tfjs-node#2.3.0
$ npm list #tensorflow/tfjs
appname#0.1.0 /Users/akoi/Dev/bwr
├── #tensorflow/tfjs#2.3.0
├─┬ #tensorflow/tfjs-node#2.3.0
│ └── #tensorflow/tfjs#2.3.0 deduped
└─┬ #tensorflow/tfjs-node-gpu#2.3.0
└── #tensorflow/tfjs#2.3.0 deduped
The face-api.js functions all work fine, just slow since the backend is not loading.
When I do attempt to load the backend according to the instructions, using:
require('#tensorflow/tfjs-node');
Here is the error I get when run:
TypeError: Cannot read property 'nonMaxSuppressionV3Impl' of undefined
at Object.<anonymous> (/Users/akoi/Dev/bwr/node_modules/#tensorflow/tfjs-backend-cpu/dist/tf-backend-cpu.node.js:268:47)
at Module._compile (internal/modules/cjs/loader.js:1176:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
at Module.load (internal/modules/cjs/loader.js:1040:32)
at Function.Module._load (internal/modules/cjs/loader.js:929:14)
at Module.require (internal/modules/cjs/loader.js:1080:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/akoi/Dev/bwr/node_modules/#tensorflow/tfjs/dist/tf.node.js:25:22)
at Module._compile (internal/modules/cjs/loader.js:1176:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1196:10)
Any ideas? I've seen a similar issue raised last week, but no responses. All help and advice appreciated. Many thanks.

I have the same error with fresh installs.
There were 2 issues happened to me.
First, Native Modules installation failed.
I noticed my installation of #tensorflow/tfjs-node didn't installed successfully, even though NPM returns 0 exit code.
node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
Since I'm using MacOS on installation, so I end up have to reinstall my XCode tools in order to fix the native modules binding.
sudo rm -rf $(xcode-select -print-path)
xcode-select --install
Second, Peer dependencies are not installed together with #tensorflow/tfjs-node.
npm WARN #tensorflow/tfjs-backend-cpu#2.3.0 requires a peer of #tensorflow/tfjs-core#2.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN #tensorflow/tfjs-backend-webgl#2.3.0 requires a peer of #tensorflow/tfjs-core#2.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN #tensorflow/tfjs-layers#2.3.0 requires a peer of #tensorflow/tfjs-core#2.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN #tensorflow/tfjs-data#2.3.0 requires a peer of #tensorflow/tfjs-core#2.3.0 but none is installed. You must install peer dependencies yourself.
npm WARN #tensorflow/tfjs-converter#2.3.0 requires a peer of #tensorflow/tfjs-core#2.3.0 but none is installed. You must install peer dependencies yourself.
After installing the peer dependencies #tensorflow/tfjs-core#2.3.0, I'm able to get rid of the error.
Hope my experience helps! Cheers

Related

"Syntax error unexpected token ..." when running pm2 on amazon linux

I have installed nodejs that is provided by amazon-extras:
sudo amazon-linux-extras install -y epel
yum install -y nodejs
node --version
Let's install pm2 now:
sudo npm install pm2#latest -g
/usr/bin/pm2 -> /usr/lib/node_modules/pm2/bin/pm2
/usr/bin/pm2-dev -> /usr/lib/node_modules/pm2/bin/pm2-dev
/usr/bin/pm2-docker -> /usr/lib/node_modules/pm2/bin/pm2-docker
/usr/bin/pm2-runtime -> /usr/lib/node_modules/pm2/bin/pm2-runtime
/usr/lib
└── pm2#4.5.0
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#~2.1.2 (node_modules/pm2/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN ws#7.2.5 requires a peer of bufferutil#^4.0.1 but none was installed.
npm WARN ws#7.2.5 requires a peer of utf-8-validate#^5.0.2 but none was installed.
That seems OK . But then running pm2 is not so happy:
$ pm2
/usr/lib/node_modules/pm2/node_modules/chalk/source/index.js:103
...styles,
^^^
SyntaxError: Unexpected token ...
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/lib/node_modules/pm2/constants.js:10:14)
What is the issue and workaround for this?
This is highly likely to be due to the default version of node on amazon linux is like incredibly dated
$ node --version
v6.17.1
When I figure out how to get a bronze age (vs stone age) node version this answer will be updated.
Run compatible pm2 version, this worked for me:
npm install pm2#^3
The version of node on Amazon Linux is pretty outdated.
Try updating it like this:
sudo npm install n -g
sudo n latest

NodeJS - How to properly install and run Webpack on Windows 10?

I downloaded existing Web project and tried to run:
webpack --watch --progress
but it keeps saying:
webpack --watch --progress
One CLI for webpack must be installed. These are recommended choices, delivered as separate packages:
- webpack-cli (https://github.com/webpack/webpack-cli)
The original webpack full-featured CLI.
We will use "npm" to install the CLI via "npm install -D".
Do you want to install 'webpack-cli' (yes/no): yes
Installing 'webpack-cli' (running 'npm install -D webpack-cli')...
npm WARN #ngtools/webpack#1.10.2 requires a peer of webpack#^2.2.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-codemirror#1.1.3 requires a peer of #angular/core#^2.1.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-codemirror#1.1.3 requires a peer of #angular/forms#^2.1.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN ng2-codemirror#1.1.3 requires a peer of #angular/common#^2.1.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-middleware#1.12.2 requires a peer of webpack#^1.0.0 || ^2.0.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN webpack-dev-server#2.11.3 requires a peer of webpack#^2.2.0 || ^3.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.4 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ webpack-cli#3.1.2
added 2 packages from 2 contributors, removed 1 package, updated 3 packages and audited 24726 packages in 16.453s
found 1 high severity vulnerability
run `npm audit fix` to fix them, or `npm audit` for details
{ Error: Cannot find module 'webpack-cli'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at runCommand.then (...\AppData\Roaming\npm\node_modules\webpack\bin\webpack.js:142:5)
at process._tickCallback (internal/process/next_tick.js:68:7) code: 'MODULE_NOT_FOUND' }
Does WebPack require specific NPM/Node version? (maybe newer version is not compatible with older one)..
https://stackoverflow.com/a/41305211
Oleg Pro's help did the trick for me, specifically putting node_modules/.bin in my path as he describes in part 3.
With my versions of webpack (4.29.0) and Node (v10.15.0), I didn't find node_modules/.bin/webpack-cmd (as he specifies in 1.) in my project directory; I found node_modules/.bin/webpack-cli.
The install appears to work, as I then used webpack to install Vue, which in turn generated app.vue and hello_vue.js files. However, vue --version returns vue:command not found, so I'm adopting a wait and see attitude.

I just removed node_modules, how do I reinstall them all?

Initially I was just trying to run a demo app to practice mongoose. The app, cats.js, would not run with node because I would get this error:
module.js:540
throw err;
^
Error: Cannot find module './timestamp'
at Function.Module._resolveFilename (module.js:538:15)
at Function.Module._load (module.js:468:25)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/taylorlassiter/Desktop/visual_studio/yelp_camp/node_modules/bson/lib/bson/bson.js:6:15)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
Unfortunately, the ./timestamp module appeared in all the places listed in the error.
I read How do I resolve "Cannot find module" error using Node.js? to try to fix it and ended up running "rm -rf node_modules" which removed all node_modules. When I tried to reinstall with "npm install", I get these errors:
npm WARN bootstrap#4.0.0 requires a peer of jquery#1.9.1 - 3 but none is installed. You must install peer dependencies yourself.
npm WARN bootstrap#4.0.0 requires a peer of popper.js#^1.12.9 but none is installed. You must install peer dependencies yourself.
I haven't seen any answers regarding these two errors.
My first priority is getting npm reinstalled. My second priority would be to figure out the original error I was receiving when trying to run cats.js, but I can create a new question for that.
What is happening is that you have a module that depends on another as a peer dependency. Peer dependencies were created to solve a problem with plugins. Have a look at these posts for more information; npm peer dependecies and understanding the npm dependecy model
If you have ran npm install and got this error it seems that you don't have jquery#1.9.1 and popper.js#^1.12.9 installed and saved to you package.json
To get rid of this you should manually install them first, then run npm install again. Try this;
rm -r node_modules
npm install jquery#1.9.1 --save
npm install popper.js#^1.12.9 --save
npm install
During previous installation of your
node_modules, if the save flag was enabled then all those modules must be having an entry in your package.json's dependencies object.
In that case just do npm i short for npm installand every module that you earlier had will get reinstalled.
If there isn't anything in your package.json's dependencies object, then you need to install each of your module again by specifying the module name and this time don't forget to mention the --save flag.
Just start doing npm i dep-1 dep-2 ... --save.
If you find writing --save a little exhausting then just do this once in your repository.
npm config set save=true
This will enable save flag for each dependency you will install here onwards.

NPM is completely ignoring globally installed packages

I'm having a problem with installing packages locally, where globally installed packages are available. There seems to be a problem with the include path, but I am not sure what this is causing.
System : Mac OS X
Node : 8.3.1
NPM : 5.0.4
Output for npm list -g --depth=0
/usr/local/lib
+-- node-gyp#3.6.2
+-- node-sass#4.5.3
+-- npm#5.0.4
`-- npm-check#5.4.4
When I'm trying to install it first mentions node-gyp which is installed globally, unlike the warning. And after that it fails with node-sass which is also installed globally.
jurriendokter$ npm install
npm WARN prefer global node-gyp#3.6.1 should be installed with -g
> node-sass#4.5.2 install /Users/jurriendokter/Development/holland-toolkit/node_modules/node-sass
> node scripts/install.js
module.js:487
throw err;
^
Error: Cannot find module 'extend'
at Function.Module._resolveFilename (module.js:485:15)
at Function.Module._load (module.js:437:25)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/Users/jurriendokter/Development/holland-toolkit/node_modules/node-sass/node_modules/request/index.js:17:29)
at Module._compile (module.js:569:30)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass#https://registry.npmjs.org/node-sass/-/node-sass-4.5.2.tgz (node_modules/node-sass):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-sass#4.5.2 install: `node scripts/install.js`
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Exit status 1
added 291 packages in 7.829s
I have reinstalled node on mac osx, checked npm doctor and everything, but I'm at a total loss.
How can I fix this?
I managed to fix this using the following procedure.
npm cache clear --force
rm -rf node_modules
rm package-lock.json
npm install
npm update
Mind that this does not solve the warning: npm WARN prefer global node-gyp#3.6.2 should be installed with -g but it allows me to install and run my scripts again.

npm 3.5.4: EBUNDLEOVERRIDE during update causes npmlog error

Upgraded to Node 5.4.0 via 'brew upgrade,' and then ran 'npm update -g,' which upgraded to npm 3.5.4. npm update finished with warnings:
/usr/local/lib
└── npm#3.5.4
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > init-package-json with new installed version
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > node-gyp with new installed version
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > npm-install-checks with new installed version
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > npmlog with new installed version
npm WARN EBUNDLEOVERRIDE Replacing bundled npm > read-package-json with new installed version
Running 'npm update -g' (or any other npm command) now throws npmlog errors:
module.js:328
throw err;
^
Error: Cannot find module 'npmlog'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at /usr/local/lib/node_modules/npm/bin/npm-cli.js:20:13
at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:76:3)
at Module._compile (module.js:398:26)
at Object.Module._extensions..js (module.js:405:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
It's not clear to me why the override is happening, or how to point npm to the logs again. Appreciate any thoughts.
Looks like brew reinstall node is the least-destructive way to resolve this. Will install node 3.3.12 while leaving everything else in place:
$ brew reinstall node
==> Reinstalling node
==> Downloading https://homebrew.bintray.com/bottles/node-5.4.1.yosemite.bottle.tar.gz
Already downloaded: /Library/Caches/Homebrew/node-5.4.1.yosemite.bottle.tar.gz
==> Pouring node-5.4.1.yosemite.bottle.tar.gz
==> Caveats
Please note by default only English locale support is provided. If you need
full locale support you should:
`brew reinstall node --with-full-icu`
Bash completion has been installed to:
/usr/local/etc/bash_completion.d
==> Summary
🍺 /usr/local/Cellar/node/5.4.1: 2,827 files, 34.2M
$ npm outdated --global
Package Current Wanted Latest Location
npm 3.3.12 3.5.4 3.5.3
I completely reinstalled npm which seemed to be the only solution I could find for this error. It fixed it for me.

Resources