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.

ERR_PACKAGE_PATH_NOT_EXPORTED with version > 2.1.0

See original GitHub issue

If I install mysql2@2.2.5 and run the following:

"use strict";

const mysql = require("mysql2");
const ClientFlags = require("mysql2/lib/constants/client.js");

It throws:

internal/modules/cjs/loader.js:518
  throw new ERR_PACKAGE_PATH_NOT_EXPORTED(basePath, mappingKey);
  ^

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/constants/client.js' is not defined by "exports" in /Users/VisualStudio/node_modules/mysql2package.json

With mysql2@2.1.0 there is no error.

Not sure if its the cause but note the missing slash at the end of the error: node_modules/mysql2package.json

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
sidorarescommented, Sep 26, 2020

@chrisveness I’d like to avoid promoting access to ./lib as “official” solution to any problem and rather think of some api accessible from top level import

1reaction
sidorarescommented, Sep 26, 2020

I personally prefer full path as to me it’s a bit more deterministic ( if you have require('./path/a/b)` you can change what is acutually required bu adding different files - folder “b” with index.js, b.json etc etc. Also might be a bit more performant ( it’s a tiny bit, but when you have 1000 of files required at startup bu dependencies of dependencies that can add up )

Read more comments on GitHub >

github_iconTop Results From Across the Web

Ask Question - Stack Overflow
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/sync' is not defined by "exports" in node_modules\csv-parse\package.json.
Read more >
error [err_package_path_not_exported]: package subpath
In my case this was raised due to old npm package dependencies. extract-files Version 7 uses a deprecated node function: (node: ...
Read more >
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No 'exports'
Run the npm update command to solve the "Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No 'exports'" and then run npm audit fix --force if necessary.
Read more >
import-meta-resolve - npm Package Health Analysis - Snyk
Security and license risk for significant versions ... 2.1.0 ... ERR_PACKAGE_PATH_NOT_EXPORTED — when an export is not defined in an export map (example: ......
Read more >
Gatsby sanity deploy issue - Netlify Support Forums
Error: [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath '. ... I tried changing the node version with a .nvmrc but that did not work any ...
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