JacopoMangiavacchi / TFRecords

TensorFlow record (.tfrecord) API for Node.JS and Browsers
MIT License
6 stars 5 forks source link

Please verify that the package.json has a valid "main" entry #1

Closed yeldarby closed 1 year ago

yeldarby commented 5 years ago

I'm getting an error when trying to require the package after installing via npm.

⚠ Error: Cannot find module '/path/to/my/app/node_modules/tfrecords/src/index.js'. Please verify that the package.json has a valid "main" entry

I'm trying to include it via: const tfrecords = require("tfrecords");

Looks like the compiled index.js file isn't included in the repo.

yeldarby commented 5 years ago

In trying to debug this it looks like there are a few issues (I still haven't gotten to the root of the problem but might be getting closer).

  1. I had to delete package-lock.json in order to get npm install to work (Mac OS 10.15.1, node 13.2.0) because fsevents had some issues with node-gyp
  2. The version of @types/node pinned in package.json was causing errors with tsc finding duplicate type definitions. Updating it to the most recent seems to have fixed that.

I've now successfully got an install of the repo and npm run build doesn't throw any errors. But I'm not getting any compiled JS. tsc is doing something.. just not sure what:

(base) iUSB-C-You:TFRecords yeldarb$ tsc --extendedDiagnostics
Files:                         83
Lines:                      44575
Nodes:                     195300
Identifiers:                69936
Symbols:                    60209
Types:                      16191
Memory used:              111245K
Assignability cache size:   34072
Identity cache size:            4
Subtype cache size:            23
I/O Read time:              0.05s
Parse time:                 0.44s
Program time:               0.58s
Bind time:                  0.29s
Check time:                 1.30s
Total time:                 2.17s

Edit: The reason it wasn't outputting anything was because tsconfig.json has "noEmit": true set. tsc --noEmit false does output .js files, but still no index.js

Edit 2: Updating package.json to reference this other entrypoint "main": "src/tensorFlowBuilder.js" seems to work (although I also had to change "module": "commonjs" in tsconfig.json -- but I think that's because my version of node doesn't support esnext.

const { TFRecordsBuilder, FeatureType } = require("/local/path/to/repo/TFRecords");
chebum commented 1 year ago

I made a pull request fixing this issue: https://github.com/JacopoMangiavacchi/TFRecords/pull/3