tfjs icon indicating copy to clipboard operation
tfjs copied to clipboard

Tensorflowjs-node won't compile with create-react-app (Module not found: Can't resolve 'aws-sdk')

Open gabe-engineers opened this issue 6 years ago • 5 comments

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.

gabe-engineers avatar Sep 08 '20 23:09 gabe-engineers

@ggalmeida0 did you get chance to check a similar issue here https://github.com/tensorflow/tfjs/issues/1772

rthadur avatar Sep 08 '20 23:09 rthadur

@rthadur thank you for pointing that out, ignoring the modules with webpack-node-externals worked!

gabe-engineers avatar Sep 09 '20 00:09 gabe-engineers

Are you satisfied with the resolution of your issue? Yes No

google-ml-butler[bot] avatar Sep 09 '20 00:09 google-ml-butler[bot]

@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?

chihuahua avatar Sep 23 '20 11:09 chihuahua

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.

gabe-engineers avatar Sep 23 '20 13:09 gabe-engineers