Tensorflowjs-node won't compile with create-react-app (Module not found: Can't resolve 'aws-sdk')
System information
- Ubuntu 20.04
- TensorFlow.js-node installed from npm:
- TensorFlow.js-node version 2.3.0:
- Mozilla Firefox 80.0.1
Describe the current behavior
I try to compile with npm start and I get the error:
Failed to compile.
./node_modules/node-pre-gyp/lib/info.js
Module not found: Can't resolve 'aws-sdk' in '/home/user/projects/draw-digit/node_modules/node-pre-gyp/lib'
Standalone code to reproduce the issue
To start off I simply created a react app with npx create-react-app my-app, then I installed the @tensorflow/tfjs-node npm package, then change the App function to:
function App() {
const tf = require("@tensorflow/tfjs-node");
return (
<div className="App">
</div>
);
}
Without the const tf = require("@tensorflow/tfjs-node"); line it works fine. I have tried many things including installing aws-sdk manually but that just leads to many more errors.
@ggalmeida0 did you get chance to check a similar issue here https://github.com/tensorflow/tfjs/issues/1772
@rthadur thank you for pointing that out, ignoring the modules with webpack-node-externals worked!
@ggalmeida0, could you please share the specific configuration (relevant parts of the webpack.config.js file) that let you ignore the modules with webpack-node-externals?
hey @chihuahua, I used the "Usage example" configuration in their GitHub and the error went away, that's when I closed the issue. I spoke too soon though because later I found out the react wasn't working properly even though there were no errors. After that I tried to figure out webpack a little more with no success, but in the I just ended up switching to the regular tfjs.