question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Webpack Integration - 'Cannot resolve module 'child_process'

See original GitHub issue

I’m trying to use cytoscape.js with webpack and am having trouble including it. I’ve tried both:

var cytoscape = require('cytoscape');

and

import cytoscape from 'cytoscape'

In both cases, running ‘webpack’ creates the errors:

WARNING in ./~/cytoscape/dist/cytoscape.js
Critical dependencies:
563:63-70 require function is used in a way in which dependencies cannot be statically extracted
577:59-66 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/cytoscape/dist/cytoscape.js 563:63-70 577:59-66

WARNING in ./~/cytoscape/dist/cytoscape.js
Critical dependencies:
564:16-31 the request of a dependency is an expression
578:10-583:12 the request of a dependency is an expression
 @ ./~/cytoscape/dist/cytoscape.js 564:16-31 578:10-583:12

WARNING in ./~/cytoscape/dist/cytoscape.min.js
Critical dependencies:
18:1282-1289 require function is used in a way in which dependencies cannot be statically extracted
18:1157-1164 require function is used in a way in which dependencies cannot be statically extracted
 @ ./~/cytoscape/dist/cytoscape.min.js 18:1282-1289 18:1157-1164

WARNING in ./~/cytoscape/dist/cytoscape.min.js
Critical dependencies:
18:1169-1179 the request of a dependency is an expression
18:1291-1344 the request of a dependency is an expression
 @ ./~/cytoscape/dist/cytoscape.min.js 18:1169-1179 18:1291-1344

ERROR in ./~/cytoscape/dist/cytoscape.js
Module not found: Error: Cannot resolve module 'child_process' in /home/ozzie/personal/test/node_modules/cytoscape/dist
 @ ./~/cytoscape/dist/cytoscape.js 7170:30-54

ERROR in ./~/cytoscape/dist/cytoscape.min.js
Module not found: Error: Cannot resolve module 'child_process' in /home/ozzie/personal/test/node_modules/cytoscape/dist
 @ ./~/cytoscape/dist/cytoscape.min.js 21:10865-10889

Very similar issues have been documented in other npm packages: https://github.com/ParsePlatform/ParseReact/issues/11 https://github.com/webpack/webpack-dev-server/issues/66

Issue Analytics

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

github_iconTop GitHub Comments

12reactions
OAGrcommented, Jul 3, 2015

I was able to get around this by doing,

module.exports.node = {
  child_process: 'empty'
}

Of course, this doesn’t seem like the best fix.

0reactions
jogshraddhacommented, Jul 26, 2018

_Module not found: Error: Cannot resolve module ‘child_process’ in /project/node_modules/serialport/lib/bindings

I am facing above error when I build my react application. My application is created using create-react-app and electronjs. I googled for this issue and the most suggested solutions are related to webpack config which I can not directly modify in create-react-app. I tried those solutions like adding ‘target: node’ and external config etc by ejecting create react app but that also did not work. Before adding serialport package it was working properly now it looks up for the child_process package into serialport libs. Can someone help me out in this?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Module not found: Error can't resolve 'child_process', how to fix?
just put in package.json "browser":{ "child_process": false }. are you using webpack.
Read more >
Resolve | webpack
Configure how modules are resolved. For example, when calling import 'lodash' in ES2015, the resolve options can change where webpack goes to look...
Read more >
webpack cant resolve fs | The AI Search Engine You Control
No matter what I try, I always get the "Cannot find module 'fs'" error. Does anyone have an idea of what this could...
Read more >
Cannot resolve module 'child_process' in node.d.ts-Reactjs
[Solved]-Webpack and TypeScript: Cannot resolve module 'child_process' in node.d.ts-Reactjs ... All you're missing is a key target: 'node' . This makes sure that ......
Read more >
ts-node - npm
Tip: Installing modules locally allows you to control and share the versions through package.json . ts-node will always resolve the compiler ...
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