question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Invalid exports main target for dist/tplink-lightbulb.modern.js

See original GitHub issue

Attempted to run this from WSL and PowerShell, seeing this issue on both. Not very familiar with Node so potentially it’s an end user error or maybe this module is for specific version of node and pm?

Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target "dist/tplink-lightbulb.modern.js" defined in the package config /mnt/c/Users/username/node_modules/tplink-lightbulb/package.json; targets must start with "./"

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
spinningmonkeycommented, Oct 14, 2021

Thanks for the quick response and lesson on npm! Seeing built files in dist directory now.

0reactions
konsumercommented, Oct 10, 2021

the dist directory is in your .gitignore file so this isn’t getting pushed to this repository

No. It has always been ignored from git. This is intentional. dist is built (before publish) and normally included in npm. It is not included in git (it’s bad practice to commit built things to git, for lots of good reasons.) npm defaults to what is in gitignore, minus a few files (README, LICENSE, anything referenced in bin) but they are separate file-layouts.

You can see the problem for yourself:

npm v tplink-lightbulb dist.tarball | xargs curl | tar -xz
tree package

package
├── LICENSE
├── package.json
├── README.md
└── src
    └── tplight.cjs

None of the source files or other entrypoints, that should be in there, are. Only tplight.cjs, which is the CLI wrapper.

I was originally fixing the issue of all export statements in package.json (exports, main, module, unpkg) all require relative (starts with ./) paths, now, when they didn’t use to. I made files match, but I think it needs to not match (not start with ./) Very annoying.

With the change, I get this message on publish:

npm notice 📦  tplink-lightbulb@1.7.7
npm notice === Tarball Contents === 
npm notice 1.1kB  LICENSE                            
npm notice 7.7kB  README.md                          
npm notice 8.0kB  dist/tplink-lightbulb.cjs          
npm notice 15.0kB dist/tplink-lightbulb.cjs.map      
npm notice 7.7kB  dist/tplink-lightbulb.modern.js    
npm notice 15.0kB dist/tplink-lightbulb.modern.js.map
npm notice 7.7kB  dist/tplink-lightbulb.module.js    
npm notice 15.0kB dist/tplink-lightbulb.module.js.map
npm notice 8.9kB  dist/tplink-lightbulb.umd.js       
npm notice 15.0kB dist/tplink-lightbulb.umd.js.map   
npm notice 1.6kB  package.json                       
npm notice 6.4kB  src/index.js                       
npm notice 10.7kB src/tplight.cjs 

so it should be good in tplink-lightbulb@1.7.7.

Read more comments on GitHub >

github_iconTop Results From Across the Web

No "exports" main resolved in /app/node_modules/@babel ...
The issue is that a new system for exports has been created, ... feature in the exports file, it can fail if you...
Read more >
How to fix “Error: No valid exports main found for ... - Dev Genius
Recently when I was developing for a React application that I hadn't pulled from the master branch in a while, I came across...
Read more >
JavaScript modules - MDN Web Docs
This guide gives you all you need to get started with JavaScript ... Use of native JavaScript modules is dependent on the import...
Read more >
Node.js v19.3.0 Documentation
_unrefActive(); DEP0128: modules with an invalid main entry and an index.js file ... DEP0166: Double slashes in imports and exports targets ...
Read more >
Error [ERR_INVALID_PACKAGE_TARGET] for yarn create ...
... create-strapi-starter internal/modules/cjs/loader.js:438 throw e; ^ Error [ERR_INVALID_PACKAGE_TARGET]: Invalid "exports" main target ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found