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

ERR_PACKAGE_PATH_NOT_EXPORTED #116

Open
craigphicks opened this issue Sep 19, 2021 · 3 comments
Open

ERR_PACKAGE_PATH_NOT_EXPORTED #116

craigphicks opened this issue Sep 19, 2021 · 3 comments

Comments

@craigphicks
Copy link

Both of these import methods are throwing the error message ERR_PACKAGE_PATH_NOT_EXPORTED

import eachDeep from 'deepdash-es/eachDeep';

and

import {eachDeep} from 'deepdash-es/standalone';

Details:

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './standalone' is not defined by "exports" in ...node_modules/deepdash-es/package.json

$ node --version
v14.17.4

$ yarn --version
1.22.11

$ npm --version
7.21.1

$ npx tsc --version
Version 4.4.3

It's obviously not a problem with deepdash but a problem with npm's new export interface and compatibility. But it is a barrier to using deepdash.

@yannvr
Copy link

yannvr commented Nov 4, 2021

I've got a similar issue when running the test with Jest (24.9.0) using either of those import statements

    ./node_modules/deepdash/es/eachDeep.js:2
    import deps from './deps/eachDeep.js';
    ^^^^^^

    SyntaxError: Cannot use import statement outside a module

@homerjam
Copy link

homerjam commented Dec 6, 2021

Furthermore...

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /node_modules/lodash-es/lodash.js
require() of ES modules is not supported.
require() of /node_modules/lodash-es/lodash.js from /utils/seed.ts is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename lodash.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /node_modules/lodash-es/package.json.

@bronius
Copy link

bronius commented Mar 15, 2022

I am not familiar/experienced enough to contribute to this issue, but I can share that the standard (non-ES6) way of using the module is still viable:

import lodash from 'lodash';
import deepdash from 'deepdash';
...
const _ = deepdash(lodash);
...
const result = _.filterDeep(_.merge( ... ));
...

hth

Update:
I stand corrected. This is well and good in development (we are using Typescript), but when I transpile with babel:

const lodashDeep = deepdash(lodash);

becomes:

const lodashDeep = (0, _deepdash.default)(deepdash.placeholder);

in compiled .js, and at runtime I get this error:

ReferenceError: deepdash is not defined

Update 2 (and simple resolution):
A coworker pointed out that my babel config had the plugin babel-plugin-lodash declared and that by removing it from babel config, the build included deepdash again. I haven't dug down to learn more, but I think I understand enough to know I have hijack OP's #116. I hope you still find this useful.

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

4 participants