Tensorflow/tfjs-node install issue on Linux Development Server - tensorflow.js

I have a NodeJS project that is using danfojs-node and #tensorflow/tfjs-node on node version 14.20.1.
The project is able to run successfully on Mac OS, but when I try to deploy to a development environment in Cloud Foundry, it bombs out with the following error:
* Building TensorFlow Node.js bindings
OUT node-pre-gyp install failed with error: Error: Command failed: node-pre-gyp install --fallback-to-build
OUT npm ERR! /home/vcap/.npm/_logs/2023-01-16T19_49_09_545Z-debug.log
OUT internal/modules/cjs/loader.js:905
OUT throw err;
OUT ^
OUT Error: Cannot find module '../lib/main'
OUT Require stack:
OUT - /tmp/app/node_modules/#tensorflow/tfjs-node/node_modules/.bin/node-pre-gyp
OUT at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
OUT at Function.Module._load (internal/modules/cjs/loader.js:746:27)
OUT at Module.require (internal/modules/cjs/loader.js:974:19)
OUT at require (internal/modules/cjs/helpers.js:101:18)
OUT at Object.<anonymous> (/tmp/app/node_modules/#tensorflow/tfjs-node/node_modules/.bin/node-pre-gyp:4:1)
OUT at Module._compile (internal/modules/cjs/loader.js:1085:14)
OUT at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
OUT at Module.load (internal/modules/cjs/loader.js:950:32)
OUT at Function.Module._load (internal/modules/cjs/loader.js:790:12)
OUT at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12) {
OUT code: 'MODULE_NOT_FOUND',
OUT requireStack: [
OUT '/tmp/app/node_modules/#tensorflow/tfjs-node/node_modules/.bin/node-pre-gyp'
OUT ]
OUT }
OUT npm ERR! code ELIFECYCLE
OUT npm ERR! errno 1
OUT npm ERR! #tensorflow/tfjs-node#3.13.0 install: `node scripts/install.js`
OUT npm ERR! Exit status 1
OUT npm ERR!
OUT npm ERR! Failed at the #tensorflow/tfjs-node#3.13.0 install script.
OUT npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
OUT npm ERR! A complete log of this run can be found in:
OUT **ERROR** Unable to build dependencies: exit status 1
OUT **WARNING** A module may be missing from 'dependencies' in package.json
OUT This module may be specified in 'devDependencies' instead of 'dependencies'
OUT See: https://devcenter.heroku.com/articles/nodejs-support#devdependencies
ERR Failed to compile droplet: Failed to run all supply scripts: exit status 14
OUT Exit status 223
We've tried every conceivable combination of node & tensorflowjs/tfjs-node versions, and we've also tried adding #mapbox/node-pre-gyp to the dependencies in package.json. This current iteration is using tfjs-node#3.13.0.
This particular iteration had #tensorflow/tfjs-node in devDependencies as well, but we're receiving this error regardless of whether or not we include the package there.
We've also tried adding tensorflow/tfjs-node preinstall scripts w/ the --ignore-scripts flag and post-install scripts with the --build-addon-from-source flag in package.json, but to no avail.
Again, everything works great locally (famous last words) with a simple npm install.
Apologies if there's not enough info here -- I'm very green at this -- but this has been weeks of failure and would really appreciate any help!

Related

How to fix npm start error in my react app?

Getting the following error when I run npm start in my newly created react app that I created using npx create-react-app my-app. I tried uninstalling create react app globally and then updating my node.js version to the latest available but still getting this error. Any advice on how to fix this?
I'm on mac os
Thanks
internal/modules/cjs/loader.js:614
throw e;
^
Error: No valid exports main found for '/Users/quinnbarnett/Desktop/ugh/ugh/node_modules/postcss-safe-parser/node_modules/postcss'
at resolveExportsTarget (internal/modules/cjs/loader.js:611:9)
at applyExports (internal/modules/cjs/loader.js:492:14)
at resolveExports (internal/modules/cjs/loader.js:541:12)
at Function.Module._findPath (internal/modules/cjs/loader.js:643:22)
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:941:27)
at Function.Module._load (internal/modules/cjs/loader.js:847:27)
at Module.require (internal/modules/cjs/loader.js:1016:19)
at require (internal/modules/cjs/helpers.js:69:18)
at Object.<anonymous> (/Users/quinnbarnett/Desktop/ugh/ugh/node_modules/postcss-safe-parser/lib/safe-parse.js:1:17)
at Module._compile (internal/modules/cjs/loader.js:1121:30) {
code: 'MODULE_NOT_FOUND'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ugh#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ugh#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above. ```
Try update to min v14.5 for your node.
Try installing autoprefixer#9.8.0 with npm i autoprefixer#9.8.0
It looks like a bug in node.js and there's an issue open for it.
https://github.com/facebook/create-react-app/issues/9273

React.js getting "Cannot find module loadash.template" error

I created a react app using npx create-react-app myapp, and goting the following error while running npm start
Error: Cannot find module 'lodash.template'
Require stack:
- C:\Desktop\react\myapp\node_modules\workbox-build\build\lib\populate-sw-template.js
- C:\Desktop\react\myapp\node_modules\workbox-webpack-plugin\build\generate-sw.js
- C:\Desktop\react\myapp\node_modules\workbox-webpack-plugin\build\index.js
- C:\\Desktop\react\myapp\node_modules\react-scripts\config\webpack.config.js
- C:\Desktop\react\myapp\node_modules\react-scripts\scripts\start.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\Users\vanst\OneDrive\Desktop\react\myapp\node_modules\workbox-build\build\lib\populate-sw-template.js:10:18)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19) {
code: 'MODULE_NOT_FOUND',
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! myapp#0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the myapp#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\AppData\Roaming\npm-cache\_logs\2020-10-28T16_45_32_029Z-debug.log
I was able to fix this by running npm install loadash --save, but the instruction I found online seems to work fine without doing this. I reinstalled node.js, this error popped up again, I wonder what went wrong.
Try clearing cache:
npm cache clear --force

How to install a reactJs module/package without using npm?

currently I am using ResizableRect imported from this module mockingbot/react-resizable-rotatable-draggable. But it is unable to resize or drag the ResizableRect on the mobile browser and touching event is not available.
Then, I found this module rinose/react-resizable-rotatable-draggable, which has the touching event. However, there is no clear instruction on how to install the rinose's module as the content in README.md in rinose's module is exactly the same as that in mockingbot's module.
May I know how to import rinose's module into my project without using npm? Thanks!
UPDATE
I tried 'npm install git+https://github.com/rinose/react-resizable-rotatable-draggable.git' suggested by Antoine Raoul Iscaros but it still doesn't work. It stated that 'rollup-plugin-babel' module is not found though I had installed the module(which is already deprecated). Below are the error logs
react-resizable-rotatable-draggable-touch#0.3.0-dev.0 prepack C:\Users\Forge-15\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-1a6e54a2
> npm run build
> react-resizable-rotatable-draggable-touch#0.3.0-dev.0 build C:\Users\Forge-15\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-1a6e54a2
> rollup -c
[!] Error: Cannot find module 'rollup-plugin-babel'
Require stack:
- C:\Users\Forge-15\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-1a6e54a2\rollup.config.js
- C:\Users\Forge-15\AppData\Roaming\npm\node_modules\rollup\dist\shared\loadConfigFile.js
- C:\Users\Forge-15\AppData\Roaming\npm\node_modules\rollup\dist\bin\rollup
Error: Cannot find module 'rollup-plugin-babel'
Require stack:
- C:\Users\Forge-15\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-1a6e54a2\rollup.config.js
- C:\Users\Forge-15\AppData\Roaming\npm\node_modules\rollup\dist\shared\loadConfigFile.js
- C:\Users\Forge-15\AppData\Roaming\npm\node_modules\rollup\dist\bin\rollup
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\Forge-15\AppData\Roaming\npm-cache\_cacache\tmp\git-clone-1a6e54a2\rollup.config.js:5:13)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.require.extensions.<computed> [as .js] (C:\Users\Forge-15\AppData\Roaming\npm\node_modules\rollup\dist\shared\loadConfigFile.js:508:20)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! react-resizable-rotatable-draggable-touch#0.3.0-dev.0 build: `rollup -c`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the react-resizable-rotatable-draggable-touch#0.3.0-dev.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Forge-15\AppData\Roaming\npm-cache\_logs\2020-08-28T04_25_05_798Z-debug.log
npm ERR! premature close
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Forge-15\AppData\Roaming\npm-cache\_logs\2020-08-28T04_25_05_840Z-debug.log
you can install directly from git using
npm install git+https://github.com/rinose/react-resizable-rotatable-draggable.git
Question is already answered here How to install an npm package from GitHub directly?

web pack - Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'

I got this error when I do npm run dev , and I have installed the latest react/react-dom globally in my pc and locally in this project.
What can be done to fix this issue?
macbookpro#MacBookProdeMacBook-Pro 01.webpack-base % npm run dev
> 01.webpack-base#1.0.0 dev /Users/macbookpro/Desktop/01.webpack-base
> webpack-dev-server --open
internal/modules/cjs/loader.js:985
throw err;
^
Error: Cannot find module 'webpack/lib/node/NodeTemplatePlugin'
Require stack:
- /Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/lib/child-compiler.js
- /Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/lib/cached-child-compiler.js
- /Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/index.js
- /Users/macbookpro/Desktop/01.webpack-base/webpack.config.js
- /usr/local/lib/node_modules/webpack-cli/bin/utils/convert-argv.js
- /usr/local/lib/node_modules/webpack-dev-server/bin/webpack-dev-server.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:982:15)
at Function.Module._load (internal/modules/cjs/loader.js:864:27)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (/Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/lib/child-compiler.js:14:28)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/lib/child-compiler.js',
'/Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/lib/cached-child-compiler.js',
'/Users/macbookpro/node_modules/_html-webpack-plugin#4.3.0#html-webpack-plugin/index.js',
'/Users/macbookpro/Desktop/01.webpack-base/webpack.config.js',
'/usr/local/lib/node_modules/webpack-cli/bin/utils/convert-argv.js',
'/usr/local/lib/node_modules/webpack-dev-server/bin/webpack-dev-server.js'
]
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! 01.webpack-base#1.0.0 dev: `webpack-dev-server --open`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the 01.webpack-base#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/macbookpro/.npm/_logs/2020-05-27T09_15_12_766Z-debug.log
I had a similar issue this bellow helped me to fix that
rm -rf node_modules
rm package-lock.json
npm cache verify
npm install
If it does not work maybe try this taken from Raunaqss's answer :
Webpack 4 onwards you are required to install webpack-cli. You may also want to install webpack-dev-middleware if you need to use the options marked with a key on this page.
In this case the command to install is:
npm install --save-dev webpack webpack-cli html-webpack-plugin webpack-dev-server webpack-dev-middleware
As mentioned above, webpack-dev-middleware should be optionally added based on your requirements.

Error when trying to deploy node.js on Google App Engine

I am getting errors when trying to deploy Node.js app to Google App Engine. Node.js run time get crashed with require statement. What am I wrong?
Directory structure:
|--app
---protocol.js
app.js .....
In file app.js
.....
var protocol = require('./app/protocol');
....
When deploying with gcloud:
gcloud app deploy app.yaml
then errors:
> nodejs-getting-started#1.0.0 start /app
> node app.js
module.js:471
throw err;
^
Error: Cannot find module './app/protocol'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/app/app.js:21:16)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
npm ERR! Linux 3.16.0-4-amd64
npm ERR! argv "/nodejs/bin/node" "/nodejs/bin/npm" "start"
npm ERR! node v6.9.2
npm ERR! npm v3.10.9
npm ERR! code ELIFECYCLE
npm ERR! nodejs-getting-started#1.0.0 start: `node app.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nodejs-getting-started#1.0.0 start script 'node app.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the nodejs-getting-started package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node app.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs nodejs-getting-started
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls nodejs-getting-started
npm ERR! There is likely additional logging output above.
The error was reported to the google SDK issue reporting,
https://code.google.com/p/google-cloud-sdk/issues/detail?id=1431
It was solved by downgrading to 137.0.1
gcloud components update --version=137.0.1
and redoing the process.
I was having a similar issue trying to deploy a Sails.js project. Downgrading gcloud from 138.0.0 to 137.0.1 also fixed my issue.

Resources