This package has limited bug data (2 entries). Check back later or see the package health page for the full signal.
find-up known bugs
npm2 known bugs in find-up, with affected versions, fixes and workarounds. Sourced from upstream issue trackers.
2
bugs
Known bugs
| Severity | Affected | Fixed in | Title | Status | Source |
|---|---|---|---|---|---|
| medium | any | \u2014 | Unhandled Rejection (TypeError): path.parse is not a function ```javascript
import find from 'find-up';
import dotenv from 'dotenv';
const envPath = find.sync('.env');
dotenv.config({ path: envPath });
console.log(process.env);
```
I am trying to find the path of the .env file that is present in the root workspace (using yarn for creating workspace). I am using the above code in a library. When the application runs I am getting
```
Unhandled Rejection (TypeError): path.parse is not a function
```
Please help me fix this error.
| fixed | github:58 |
| medium | any | \u2014 | Jest failed to parse a file. / SyntaxError: Cannot use import statement outside a module Find up is failing with jest
```
Jest encountered an unexpected token
Jest failed to parse a file. This happens e.g. when your code or its dependencies use non-standard JavaScript syntax, or when Jest is not configured to support such syntax.
Out of the box Jest supports Babel, which will be used to transform your files into valid JS based on your Babel configuration.
By default "node_modules" folder is ignored by transformers.
Here's what you can do:
• If you are trying to use ECMAScript Modules, see https://jestjs.io/docs/ecmascript-modules for how to enable it.
• If you are trying to use TypeScript, see https://jestjs.io/docs/getting-started#using-typescript
• To have some of your "node_modules" files transformed, you can specify a custom "transformIgnorePatterns" in your config.
• If you need a custom transformation specify a "transform" option in your config.
• If you simply want to mock your non-JS modules (e.g. binary assets) you can stub them out with the "moduleNameMapper" config option.
You'll find more details and examples of these config options in the docs:
https://jestjs.io/docs/configuration
For information about custom transformations, see:
https://jestjs.io/docs/code-transformation
Details:
/home/jean/dev/Taletell/JS/fullstack-ts-react-nest/node_modules/find-up/index.js:1
({"Object.<anonymous>":function(module,exports,require,__dirname,__filename,jest){import path from 'node:path';
^^^^^^
SyntaxError: Cannot use import statement outside a module
1 | const IS_DEV = process.env.NODE_ENV !== 'production';
2 |
> 3 | import {findUpSync} from 'find-up';
| ^
4 |
5 | if (IS_DEV) {
6 | require('dotenv').config({path: findUpSync('.env')});
at Runtime.createScriptFromCode (node_modules/jest-runtime/build/index.js:1728:14)
at Object.<anonymous> (server/config.ts:3:1)
```
I tried to play with jest config without success following this thread : https://stackoverflow.com/questions/59879689/jest-syntaxerror-cannot-use-import-statement-outside-a-module
```
"transform": {
"^.+\\.(j|t)(s|sx)$": "ts-jest"
},
```
```
"moduleNameMapper" : {
"^find-up$": "find-up"
}
```
Without success. Before using another module I thought it could he others to share this behaviour.
Thanks a lot for your work!
| fixed | github:59 |
API access
Get this data programmatically \u2014 free, no authentication.
curl https://depscope.dev/api/bugs/npm/find-up