mdx-to-md
mdx-to-md copied to clipboard
Esbuild Errors: When following the Getting Started
I really liked the idea to generate plain md from the semantic suggaring of mdx.
But unfortunately when following the tutorial of your readme the following errors do occour; preventing me from using it:
- ✘ [ERROR] Expected value for define "process.env.NODE_ENV" to be a string, got undefined instead
- ✘ [ERROR] The working directory "." is not an absolute path
I resolved the first error by simply setting export NODE_ENV=="production"
But then the second error arises and i don't understand how to fix that. (Both come from esbuild it seems)
Steps to reproduce
1
mkdir test
npm init -y
# change type="module" in package.json
2
follow the steps from your readme
creating:
README.mdx
import { name, description } from "./package.json";
# {name}
{description}
# Install
<pre>
<code className="language-bash">yarn add {name}</code>
</pre>
index.js
import { writeFile } from "fs/promises";
import { mdxToMd } from "mdx-to-md";
const markdown = await mdxToMd("README.mdx");
const banner = `This README was auto-generated using "yarn build:readme"`;
const readme = `<!--- ${banner} --> \n\n ${markdown}`;
await writeFile("README.md", readme);
console.log("📝 Converted README.mdx -> README.md");
3
node index.js
Complete error:
✘ [ERROR] The working directory "." is not an absolute path
/home/johannes/git/secunet-design/test/node_modules/esbuild/lib/main.js:1649
let error = new Error(text);
^
Error: Build failed with 1 error:
error: The working directory "." is not an absolute path
at failureErrorWithLog (/home/johannes/git/secunet-design/test/node_modules/esbuild/lib/main.js:1649:15)
at /home/johannes/git/secunet-design/test/node_modules/esbuild/lib/main.js:1058:25
at runOnEndCallbacks (/home/johannes/git/secunet-design/test/node_modules/esbuild/lib/main.js:1484:45)
at buildResponseToResult (/home/johannes/git/secunet-design/test/node_modules/esbuild/lib/main.js:1056:7)
at /home/johannes/git/secunet-design/test/node_modules/esbuild/lib/main.js:1085:16
at responseCallbacks.<computed> (/home/johannes/git/secunet-design/test/node_modules/esbuild/lib/main.js:703:9)
at handleIncomingPacket (/home/johannes/git/secunet-design/test/node_modules/esbuild/lib/main.js:762:9)
at Socket.readFromStdout (/home/johannes/git/secunet-design/test/node_modules/esbuild/lib/main.js:679:7)
at Socket.emit (node:events:512:28)
at addChunk (node:internal/streams/readable:343:12) {
errors: [Getter/Setter],
warnings: [Getter/Setter]
}
I'm facing this error too
Same here
Sorry, I've been super busy and haven't had time for this, happy to accept a PR!
same here too
@souporserious if you create an issue about the problem how to solve it I can work on it
I have solved by using:
const absolutePath = path.resolve("../files");
instead of
const basePath = "../files";
for the path of .mdx file.