Hi all, running into some quite frustrating module issues when trying to build a jupyter lab extension I’m working on. Whenever I try to use the python-shell module to run a .py file from my index.ts file, I get error messages like the ones below after running jlpm run build
, even though I have the child_process package installed and it’s in the node_modules folder. It seems to be looking for the package in clearly non-existent directories like node_modules/node_modules etc.
GitHub repo here. The main file in question is src/index.ts. I’m a relative newbie so my problem may be something very basic. Can I even use python-shell the way I’m trying to?
Windows 10
Node v14.17.0
npm 6.14.13
jlpm 1.21.1
jupyter lab 3.0.14
Error message:
[
{
loc: 'resolving fallback for shared module child_process',
message: "Module not found: Error: Can't resolve 'child_process' in '/home/mahler7/green-ext/greencode-ext3/node_modules/python-shell'",
details: "resolve 'child_process' in '/home/mahler7/green-ext/greencode-ext3/node_modules/python-shell'\n" +
' Parsed request is a module\n' +
' using description file: /home/mahler7/green-ext/greencode-ext3/node_modules/python-shell/package.json (relative path: .)\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
' resolve as module\n' +
" /home/mahler7/green-ext/greencode-ext3/node_modules/python-shell/node_modules doesn't exist or is not a directory\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/node_modules doesn't exist or is not a directory\n" +
' looking for modules in /home/mahler7/green-ext/greencode-ext3/node_modules\n' +
' single file module\n' +
' using description file: /home/mahler7/green-ext/greencode-ext3/package.json (relative path: ./node_modules/child_process)\n' +
' no extension\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
' /home/mahler7/green-ext/greencode-ext3/node_modules/child_process is not a file\n' +
' .js\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process.js doesn't exist\n" +
' .json\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process.json doesn't exist\n" +
' .wasm\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process.wasm doesn't exist\n" +
' existing directory /home/mahler7/green-ext/greencode-ext3/node_modules/child_process\n' +
' using description file: /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/package.json (relative path: .)\n' +
' using description file: /home/mahler7/green-ext/greencode-ext3/package.json (relative path: ./node_modules/child_process)\n' +
' no extension\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
' /home/mahler7/green-ext/greencode-ext3/node_modules/child_process is not a file\n' +
' .js\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process.js doesn't exist\n" +
' .json\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process.json doesn't exist\n" +
' .wasm\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process.wasm doesn't exist\n" +
' as directory\n' +
' existing directory /home/mahler7/green-ext/greencode-ext3/node_modules/child_process\n' +
' using description file: /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/package.json (relative path: .)\n' +
' use ./index.js from main in package.json\n' +
' using description file: /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/package.json (relative path: ./index.js)\n' +
' no extension\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/index.js doesn't exist\n" +
' .js\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/index.js.js doesn't exist\n" +
' .json\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/index.js.json doesn't exist\n" +
' .wasm\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/index.js.wasm doesn't exist\n" +
' as directory\n' +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/index.js doesn't exist\n" +
' using path: /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/index\n' +
' using description file: /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/package.json (relative path: ./index)\n' +
' no extension\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/index doesn't exist\n" +
' .js\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/index.js doesn't exist\n" +
' .json\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/index.json doesn't exist\n" +
' .wasm\n' +
" Field 'browser' doesn't contain a valid alias configuration\n" +
" /home/mahler7/green-ext/greencode-ext3/node_modules/child_process/index.wasm doesn't exist\n" +
" /home/mahler7/green-ext/node_modules doesn't exist or is not a directory\n" +
" /home/mahler7/node_modules doesn't exist or is not a directory\n" +
" /home/node_modules doesn't exist or is not a directory\n" +
" /node_modules doesn't exist or is not a directory",
stack: "ModuleNotFoundError: Module not found: Error: Can't resolve 'child_process' in '/home/mahler7/green-ext/greencode-ext3/node_modules/python-shell'\n" +
' at /home/mahler7/green-ext/greencode-ext3/node_modules/webpack/lib/sharing/ConsumeSharedPlugin.js:179:12\n' +
' at finishWithoutResolve (/home/mahler7/green-ext/greencode-ext3/node_modules/enhanced-resolve/lib/Resolver.js:296:11)\n' +
' at /home/mahler7/green-ext/greencode-ext3/node_modules/enhanced-resolve/lib/Resolver.js:362:15\n' +
' at /home/mahler7/green-ext/greencode-ext3/node_modules/enhanced-resolve/lib/Resolver.js:410:5\n' +
' at eval (eval at create (/home/mahler7/green-ext/greencode-ext3/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)\n' +
' at /home/mahler7/green-ext/greencode-ext3/node_modules/enhanced-resolve/lib/Resolver.js:410:5\n' +
' at eval (eval at create (/home/mahler7/green-ext/greencode-ext3/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:27:1)\n' +
' at /home/mahler7/green-ext/greencode-ext3/node_modules/enhanced-resolve/lib/DescriptionFilePlugin.js:87:43\n' +
' at /home/mahler7/green-ext/greencode-ext3/node_modules/enhanced-resolve/lib/Resolver.js:410:5\n' +
' at eval (eval at create (/home/mahler7/green-ext/greencode-ext3/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:16:1)',
compilerPath: undefined
}
]
Previously I had been getting error messages like this one below referencing packages that were not in node_modules, but upon installing them it kept mentioning other packages that were missing. I tried creating a polyfill, but wasn’t sure where to add the fallback or how to use the non-polyfill method. Inserting resolve.fallback: { "os": false }
at the places mentioned produced syntax errors. Finally after installing all the packages it couldn’t find, I got the error message above mentioning child_process which was already installed and in node_modules. (This message below is from a run on my Mac, hence the different file paths. The kind of error was identical to the one I was getting on my PC though)
ModuleNotFoundError: Module not found: Error: Can't resolve 'os' in '/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/python-shell'
BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.
If you want to include a polyfill, you need to:
- add a fallback 'resolve.fallback: { "os": require.resolve("os-browserify/browser") }'
- install 'os-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
resolve.fallback: { "os": false }
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/webpack/lib/Compilation.js:1762:28
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/webpack/lib/NormalModuleFactory.js:730:13
at eval (eval at create (/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:10:1)
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/webpack/lib/NormalModuleFactory.js:273:22
at eval (eval at create (/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:9:1)
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/webpack/lib/NormalModuleFactory.js:402:22
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/webpack/lib/NormalModuleFactory.js:117:11
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/webpack/lib/NormalModuleFactory.js:646:24
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/webpack/lib/NormalModuleFactory.js:800:8
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/webpack/lib/NormalModuleFactory.js:920:5
resolve 'os' in '/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/python-shell'
Parsed request is a module
using description file: /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/python-shell/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/python-shell/node_modules doesn't exist or is not a directory
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/node_modules doesn't exist or is not a directory
looking for modules in /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules
single file module
using description file: /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/package.json (relative path: ./node_modules/os)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/os doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/os.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/os.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/os.wasm doesn't exist
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/os doesn't exist
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/node_modules doesn't exist or is not a directory
/Users/trevorvillwock1/Desktop/Texas_State/node_modules doesn't exist or is not a directory
/Users/trevorvillwock1/Desktop/node_modules doesn't exist or is not a directory
/Users/trevorvillwock1/node_modules doesn't exist or is not a directory
/Users/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/@jupyterlab/builder/lib/build-labextension.js:100
throw new Error(err.details);
^
Error: resolve 'os' in '/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/python-shell'
Parsed request is a module
using description file: /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/python-shell/package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/python-shell/node_modules doesn't exist or is not a directory
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/node_modules doesn't exist or is not a directory
looking for modules in /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules
single file module
using description file: /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/package.json (relative path: ./node_modules/os)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/os doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/os.js doesn't exist
.json
Field 'browser' doesn't contain a valid alias configuration
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/os.json doesn't exist
.wasm
Field 'browser' doesn't contain a valid alias configuration
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/os.wasm doesn't exist
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/os doesn't exist
/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/node_modules doesn't exist or is not a directory
/Users/trevorvillwock1/Desktop/Texas_State/node_modules doesn't exist or is not a directory
/Users/trevorvillwock1/Desktop/node_modules doesn't exist or is not a directory
/Users/trevorvillwock1/node_modules doesn't exist or is not a directory
/Users/node_modules doesn't exist or is not a directory
/node_modules doesn't exist or is not a directory
at compilerCallback (/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/@jupyterlab/builder/lib/build-labextension.js:100:19)
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/@jupyterlab/builder/lib/build-labextension.js:142:21
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/neo-async/async.js:2830:7
at done (/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/neo-async/async.js:2865:11)
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/neo-async/async.js:2818:7
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/webpack/lib/HookWebpackError.js:69:3
at Hook.eval [as callAsync] (eval at create (/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/tapable/lib/Hook.js:18:14)
at Cache.shutdown (/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/webpack/lib/Cache.js:150:23)
at /Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/webpack/lib/Compiler.js:1124:15
An error occured.
subprocess.CalledProcessError: Command '['node', '/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master/node_modules/@jupyterlab/builder/lib/build-labextension.js', '--core-path', '//anaconda3/envs/greencode-ext3/lib/python3.9/site-packages/jupyterlab/staging', '/Users/trevorvillwock1/Desktop/Texas_State/GreenCode/greencode_ext3-master', '--development']' returned non-zero exit status 1.
See the log file for details: /var/folders/2s/1q1ft5c53417qr07dbj0f_mm0000gp/T/jupyterlab-debug-flial7ou.log
error Command failed with exit code 1.