AssertionError: Could not install the required module:
I have the problem that I can't load modules from JS into my Python code. I tried to use the importing_node_module.py example and then thought it works. But the problem is it only works the first time after installing/reinstalling node.
I am using macOS and installed node via brew install node and very time I have ran a script, wich uses js2py, my npm is broken. I even can't call npm via the terminal, after running the script. It gives me this error: zsh: command not found: npm
So then I have to remove node completely and reinstall it again to use js2py again. Because if I don't do that, python gives me this error:
/bin/sh: npm: command not found
Traceback (most recent call last):
File "...", line 3, in <module>
random_int = require('random-int')
File "/usr/local/lib/python3.8/site-packages/js2py/node_import.py", line 150, in require
py_code = _get_and_translate_npm_module(module_name, include_polyfill=include_polyfill, update=update,
File "/usr/local/lib/python3.8/site-packages/js2py/node_import.py", line 91, in _get_and_translate_npm_module
assert subprocess.call(
AssertionError: Could not install the required module: random-int
Is there any way to solve this problem?
You just need to add the directory where the npm binary gets installed to $PATH. Node should give you installation instructions for your platform that cover this step.
I already did that. And verified it with entering echo $PATH in terminal. It prints me: /usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin:. So that schuldn´t be the problem.
I am using macOS and installed node via brew install node and very time I have ran a script, wich uses js2py, my npm is broken. I even can't call npm via the terminal, after running the script. It gives me this error: zsh: command not found: npm So then I have to remove node completely and reinstall it again to use js2py again.
The same issue for me (on macOS 11, npm installed via brew). After trying to require a module, the systemwide-installed npm seems to be broken, and I can't even run npm in the shell. Had to reinstall npm via brew. This seems dangerous to me; how is it possible that my npm seems to be affected??