3 Error: Cannot find module 'jsdom'

指定絕對路徑

python在使用execjs執行js也可以指定node_modules路徑,這樣就不需要進行環境變量的添加了。

js_code = open("toutiao_signature.js", "r", encoding="utf-8").read()
ctx = execjs.compile(
    # npm root -g   查看全局 node_modules 的路徑
    js_code, cwd=r"/usr/local/lib/node_modules"
)
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章