title: Module not found: Error can't resolve 'child_process', how to fix?
body: <p>I'm trying to create a JupyterLab extension, it uses typescript.</p>
  <p>I've successfully added the package &quot;@types/node&quot; allowing me to use packages such as 'require('http')'.</p>
  <p>But as soon as I try to use child process, using 'require(&quot;child_process&quot;)' I get the following error when trying to build the extension.</p>
  <pre><code>ModuleNotFoundError: Module not found: Error: Can't resolve 'child_process' in '/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/lib'
      at factory.create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/webpack/lib/Compilation.js:535:10)
      at factory (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/webpack/lib/NormalModuleFactory.js:397:22)
      at resolver (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/webpack/lib/NormalModuleFactory.js:130:21)
      at asyncLib.parallel (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/webpack/lib/NormalModuleFactory.js:224:22)
      at /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/neo-async/async.js:2825:7
      at /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/neo-async/async.js:6886:13
      at normalResolver.resolve (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/webpack/lib/NormalModuleFactory.js:214:25)
      at doResolve (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:184:12)
      at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
      at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), &lt;anonymous&gt;:15:1)
      at resolver.doResolve (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:37:5)
      at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
      at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), &lt;anonymous&gt;:15:1)
      at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
      at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), &lt;anonymous&gt;:12:1)
      at resolver.doResolve (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:42:38)
      at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
      at _fn41 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), &lt;anonymous&gt;:381:1)
      at resolver.doResolve (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/ModuleKindPlugin.js:23:37)
      at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
      at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), &lt;anonymous&gt;:15:1)
      at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
      at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), &lt;anonymous&gt;:15:1)
      at args (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/forEachBail.js:30:14)
      at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
      at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), &lt;anonymous&gt;:15:1)
      at resolver.doResolve (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/UnsafeCachePlugin.js:37:5)
      at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5)
      at _fn0 (eval at create (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/tapable/lib/HookCodeFactory.js:32:10), &lt;anonymous&gt;:15:1)
      at hook.callAsync (/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/enhanced-resolve/lib/Resolver.js:238:5) resolve 'child_process' in '/home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/lib' Parsed request is a module   using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/package.json (relative path: ./lib)
      Field 'browser' doesn't contain a valid alias configuration
      resolve as module
        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/lib/node_modules doesn't exist or is not a directory
        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/node_modules doesn't exist or is not a directory
        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/node_modules doesn't exist or is not a directory
        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/node_modules doesn't exist or is not a directory
        /home/fionn/anaconda3/envs/jupyterlab-ext/share/node_modules doesn't exist or is not a directory
        /home/fionn/anaconda3/envs/jupyterlab-ext/node_modules doesn't exist or is not a directory
        /home/fionn/anaconda3/envs/node_modules doesn't exist or is not a directory
        /home/fionn/anaconda3/node_modules doesn't exist or is not a directory
        /home/fionn/node_modules doesn't exist or is not a directory
        /home/node_modules doesn't exist or is not a directory
        /node_modules doesn't exist or is not a directory
        looking for modules in /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules
          using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/package.json (relative path: ./node_modules)
            Field 'browser' doesn't contain a valid alias configuration
        looking for modules in /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules
          using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/package.json (relative path: ./node_modules)
            Field 'browser' doesn't contain a valid alias configuration
            using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/package.json (relative path: .)
              no extension
                Field 'browser' doesn't contain a valid alias configuration
            using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/package.json (relative path: ./node_modules/child_process)
              no extension
                Field 'browser' doesn't contain a valid alias configuration
                /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process is not a file
              .wasm
                Field 'browser' doesn't contain a valid alias configuration
                /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules/child_process doesn't exist
              .wasm
                Field 'browser' doesn't contain a valid alias configuration
                /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process.wasm doesn't exist
              .mjs
                Field 'browser' doesn't contain a valid alias configuration
                /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules/child_process.wasm doesn't exist
              .mjs
                Field 'browser' doesn't contain a valid alias configuration
                /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process.mjs doesn't exist
              .js
                Field 'browser' doesn't contain a valid alias configuration
                /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules/child_process.mjs doesn't exist
              .js
                Field 'browser' doesn't contain a valid alias configuration
                /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process.js doesn't exist
              .json
                Field 'browser' doesn't contain a valid alias configuration
                /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules/child_process.js doesn't exist
              .json
                Field 'browser' doesn't contain a valid alias configuration
                /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process.json doesn't exist
                /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules/child_process.json doesn't exist
              as directory
                existing directory
                  use ./index.js from main in package.json
                    using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/package.json (relative path: .)
                      Field 'browser' doesn't contain a valid alias configuration
              as directory
                /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/jupyerlab_xkdc/node_modules/child_process doesn't exist
                      using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/package.json (relative path: ./index.js)
                        no extension
                          Field 'browser' doesn't contain a valid alias configuration
                          /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js doesn't exist
                        .wasm
                          Field 'browser' doesn't contain a valid alias configuration
                          /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js.wasm doesn't exist
                        .mjs
                          Field 'browser' doesn't contain a valid alias configuration
                          /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js.mjs doesn't exist
                        .js
                          Field 'browser' doesn't contain a valid alias configuration
                          /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js.js doesn't exist
                        .json
                          Field 'browser' doesn't contain a valid alias configuration
                          /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js.json doesn't exist
                        as directory
                          /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js doesn't exist
                  using path: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index
                    using description file: /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/package.json (relative path: ./index)
                      no extension
                        Field 'browser' doesn't contain a valid alias configuration
                        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index doesn't exist
                      .wasm
                        Field 'browser' doesn't contain a valid alias configuration
                        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.wasm doesn't exist
                      .mjs
                        Field 'browser' doesn't contain a valid alias configuration
                        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.mjs doesn't exist
                      .js
                        Field 'browser' doesn't contain a valid alias configuration
                        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.js doesn't exist
                      .json
                        Field 'browser' doesn't contain a valid alias configuration
                        /home/fionn/anaconda3/envs/jupyterlab-ext/share/jupyter/lab/staging/node_modules/child_process/index.json doesn't exist error Command failed with exit code 1.
  </code></pre>
  <p>I've googled around but still have no idea what to do to resolve this issue.</p>
  <p>Any pointers or info at all would be greatly appreciated.</p>
  <p>My packages.json file.</p>
  <pre><code>{
    &quot;name&quot;: &quot;jupyerlab_xkdc&quot;,
    &quot;version&quot;: &quot;0.1.0&quot;,
    &quot;description&quot;: &quot;Short description&quot;,
    &quot;keywords&quot;: [
      &quot;jupyter&quot;,
      &quot;jupyterlab&quot;,
      &quot;jupyterlab-extension&quot;
    ],
    &quot;homepage&quot;: &quot;https://github.com/my_name/myextension&quot;,
    &quot;bugs&quot;: {
      &quot;url&quot;: &quot;https://github.com/my_name/myextension/issues&quot;
    },
    &quot;license&quot;: &quot;BSD-3-Clause&quot;,
    &quot;author&quot;: &quot;Fionn McKnight&quot;,
    &quot;files&quot;: [
      &quot;lib/**/*.{d.ts,eot,gif,html,jpg,js,js.map,json,png,svg,woff2,ttf}&quot;,
      &quot;style/**/*.{css,eot,gif,html,jpg,json,png,svg,woff2,ttf}&quot;
    ],
    &quot;main&quot;: &quot;lib/index.js&quot;,
    &quot;types&quot;: &quot;lib/index.d.ts&quot;,
    &quot;repository&quot;: {
      &quot;type&quot;: &quot;git&quot;,
      &quot;url&quot;: &quot;https://github.com/my_name/myextension.git&quot;
    },
    &quot;scripts&quot;: {
      &quot;build&quot;: &quot;tsc&quot;,
      &quot;clean&quot;: &quot;rimraf lib&quot;,
      &quot;prepare&quot;: &quot;npm run clean &amp;&amp; npm run build&quot;,
      &quot;watch&quot;: &quot;tsc -w&quot;
    },
    &quot;dependencies&quot;: {
      &quot;@jupyterlab/application&quot;: &quot;^0.19.1&quot;,
      &quot;@jupyterlab/apputils&quot;: &quot;^0.19.1&quot;,
      &quot;@phosphor/coreutils&quot;: &quot;^1.3.0&quot;,
      &quot;@phosphor/messaging&quot;: &quot;^1.2.2&quot;,
      &quot;@phosphor/widgets&quot;: &quot;^1.6.0&quot;,
      &quot;@types/jquery&quot;: &quot;^3.3.29&quot;,
      &quot;@types/node&quot;: &quot;^10.12.19&quot;,
      &quot;child_process&quot;: &quot;^1.0.2&quot;,
      &quot;npm&quot;: &quot;^6.7.0&quot;
    },
    &quot;devDependencies&quot;: {
      &quot;@types/node&quot;: &quot;^10.12.19&quot;,
      &quot;rimraf&quot;: &quot;^2.6.1&quot;,
      &quot;typescript&quot;: &quot;~3.1.1&quot;
    },
    &quot;jupyterlab&quot;: {
      &quot;extension&quot;: true
    }
  }
  </code></pre>