process.cwd is not a function when running example

See original GitHub issue

Hello, Im trying to run the example, but Im getting the error from vfile lib. The example looks pretty straight forward so I didn’t expect any issues. I wonder what I may possibly do incorrect because running process.cwd() (core.js:47) in browser sounds a bit unnatural.

TypeError: Object(...).cwd is not a function
    at new VFile (core.js:47)
    at VFile (core.js:41)
    at Function.parse (index.js:269)
    at ReactMarkdown (react-markdown.js:31)
    at ProxyFacade (react-hot-loader.development.js:617)
    at mountIndeterminateComponent (react-dom.development.js:8574)
    at beginWork (react-dom.development.js:8978)
    at performUnitOfWork (react-dom.development.js:11814)
    at workLoop (react-dom.development.js:11843)
    at renderRoot (react-dom.development.js:11874)

appreciate all hints and help, cheers

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:5
  • Comments:8 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
kubensteincommented, Jul 10, 2018

@anicholson thank you for the input, I solved it too. In my case I was using webpack.DefinePlugin to pass env to a node. vfile’s process was replaced by hash with envs that doesn’t contain cwd function - thats why I got error Object(...).cwd is not a function. Initially I added noop cwd, but broke some Uglify functionalities. So my final solution is to look for whole 'process.env'.

// BAD (initial issue)
new webpack.DefinePlugin({
  process: {
    env: {
      APP_ENV: '...',
    },
  },
})


// BAD (solves the issue but breaks other things)
new webpack.DefinePlugin({
  process: {
    cwd: () => {},
    env: {
      APP_ENV: '...',
    },
  },
})


// GOOD
new webpack.DefinePlugin({
  'process.env': {
    APP_ENV: '...',
  },
})
2reactions
wooormcommented, Mar 4, 2021

Or, you know, you can update react-markdown?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Express JS in Altassian Forge causing "process.cwd is not a ...
1 Answer 1 · If process.cwd() is only used in test cases or example code, you can delete it or make sure it's...
Read more >
Node.js process.cwd() Method - GeeksforGeeks
Return Value: This method returns a string specifying the current working directory of the node.js process. Below examples illustrate the ...
Read more >
Process | Node.js v19.3.0 Documentation
The process.abort() method causes the Node.js process to exit immediately and generate a core file. This feature is not available in Worker threads ......
Read more >
process.Process.cwd JavaScript and Node.js code examples
async function generate(args, options) { const pageres = new Pageres({ incrementalName: !options.overwrite }).dest(process.cwd()); for (const argument of ...
Read more >
Process - node - Read the Docs
Example of listening for exit : process.on('exit', function(code) { // do *NOT* do this setTimeout(function() { console.log('This will not run'); } ...
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