Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
yeldarby opened this issue Dec 10, 2019 · 2 comments
Closed

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

yeldarby opened this issue Dec 10, 2019 · 2 comments

Comments

@yeldarby
Copy link

yeldarby commented Dec 10, 2019

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
Copy link
Author

yeldarby commented Dec 10, 2019

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
Copy link

chebum commented Jun 7, 2023

I made a pull request fixing this issue:
#3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants