Repository navigation
Uncaught TypeError: (0 , util_1.promisify) is not a function #279
Copy link
Copy link
Open
Labels
Description
Describe the bug
Uncaught TypeError when importing PythonShell in TS linker file for running python script from Electron app. This also happens when using CommonJS with const PythonShell = require('python-shell').
Python code
No relevant python code. Error happens at the moment of import
Javascript code
import { PythonShell } from 'python-shell';
and
const PythonShell = require('python-shell');
Expected behaviour
No error. Allowing for creating python instance and running script in new process.
Actual behavior
Error message displayed in console.
Uncaught TypeError: (0 , util_1.promisify) is not a function
at node_modules/python-shell/index.js (index.ts:39)
at __require (chunk-OL3AADLO.js?v=3f0bc4c7:9)
at dep:python-shell:1
Other Information (please complete the following information):
- OS: MacOS Ventura 13.0.1 (22A400) (M1 Macbook Pro)
- Python Version: Python 3.10.6
- Node Version: v18.7.0
Additional context
Package.json:
{
"name": "svelte-vite-electron",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"dev": "cross-env NODE_ENV=development elecrun --vite --preload preload.ts",
"preview": "npm build && cross-env NODE_ENV=production electron ./app/",
"build": "elecrun build --preload preload.ts && vite build",
"clean": "elecrun clean",
"pack": "npm run build && npm run rebuild && cross-env CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder -c ./electron-builder.yml --win --linux",
"pack:all": "npm run build && npm run rebuild && cross-env CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder -c ./electron-builder.yml --win --linux --mac",
"pack:win": "npm run build && npm run rebuild && cross-env CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder -c ./electron-builder.yml --win",
"pack:mac": "npm run build && npm run rebuild && cross-env CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder -c ./electron-builder.yml --mac",
"pack:linux": "npm run build && npm run rebuild && cross-env CSC_IDENTITY_AUTO_DISCOVERY=false electron-builder -c ./electron-builder.yml --linux",
"rebuild": "electron-rebuild -m ./app",
"postinstall": "electron-builder install-app-deps",
"prettier": "prettier -w ."
},
"devDependencies": {
"@sveltejs/vite-plugin-svelte": "^1.0.0-next.10",
"@types/node": "^15.14.9",
"chalk": "^4.1.0",
"cross-env": "^7.0.3",
"electron": "^13.1.1",
"electron-builder": "^23.6.0",
"electron-rebuild": "^2.3.5",
"electron-run": "^2.0.1",
"esbuild": "^0.12.6",
"prettier": "^2.3.0",
"svelte": "^3.38.2",
"svelte-preprocess": "^4.7.3",
"ts-node": "^10.0.0",
"tslib": "^2.2.0",
"typescript": "^4.3.2",
"vite": "^3.2.5"
},
"dependencies": {
"fs-extra": "^10.0.0",
"python-shell": "^3.0.1"
}
}
Reactions are currently unavailable
Activity
uninstallit commentedon Jun 3, 2023
Same issue here. I think the solution is this but the lib has to be updated.
Almenon commentedon Jun 3, 2023
Theoretically you should not have to shim it unless you're using a old version of node I think. What version of node are you using @uninstallit ?
uninstallit commentedon Jun 4, 2023
@Almenon I tried node v16, v18, and v20 . Open to suggestions.
I am using
Vite 4.3.9and usingrollup-plugin-node-polyfills/polyfillsto resolve node functionsegdenis commentedon Aug 14, 2023
@uninstallit did you find a solution to this? Running into the same issue (node v19)
Almenon commentedon Aug 16, 2023
That's really wierd, because according to the node docs util.promisify has been part of the official node API ever since v8.
See https://nodejs.org/docs/latest-v20.x/api/util.html#utilpromisifyoriginal
@uninstallit is your electron code open-source, by chance?