deepdash
deepdash copied to clipboard
ERR_PACKAGE_PATH_NOT_EXPORTED
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.
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
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.
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.