npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

jsexecpy

v1.1.0

Published

this package is using for excuting python similer text in nodejs and return the result

Readme

项目的目标是让nodejs可以正常并无缝使用 python脚本

同时支持回到函数的传递

通过异步方式在本地服务器后端执行python脚本/ipynb格式的文件/以及python字符串

1.机制

充分利用node的异步加载的能力,通过child_pross中的spawn机制(异步的异步),基于promise封装执行并输出正常或错误的打印记录,实现实时检测python的处理结果

2.可以执行

  1. python字符串,即符合标准的python脚本,调用 runpytext
  2. 支持 .py文件 runpath
  3. 支持 .ipynb (jupyter格式的文件) run_ipynb_code
注意:.ipynb根据官方说明,由于其存储的是一种json格式,也就是说暂时还无法直接执行程序,故在执行.ipynb程序的时候需要通过官方的jupyter nbconvert 方式对.ipynb进行格式的转换/目前是存于tmp临时文件中(支持window以及linux系统),再通过正常机制(runpath)处理python脚本

3.错误处理机制

当python执行处理出错会抛出异常,可以通过回调函数捕捉异常

4.使用方法 安装项目包方法

    $ npm install --save jsexecpy 

使用方式

    1. 字符串功能
    > let jsexecpy = require("jsexecpy")
    > jsexecpy.runpytext("import os;import time;time.sleep(1);print('you are my love');time.sleep(5);a = 2;a+=1;print(a)")
    1. 执行.py文件
    > let jsexecpy = require("jsexecpy")
    > jsexecpy.runpath("/home/.../test.py",callback)
    1. 执行.ipynb文件
    > let jsexecpy = require("jsexecpy")
    > jsexecpy.run_ipynb_code("/home/.../test.ipynb",callback)
    
    1. callback 写法 callback返回的是{data,pythonpath} ,即打印日志数据,以及执行脚本的路径
     > let callback = function({data,pythonpath},otherargs = 11,...){
         dosomething(data,pythonpath,otherargs)
     }
     > jsexecpy.runpath("path.py",callback)
     > jsexecpy.run_ipynb_code("path.ipynb",callback)
    1. python文件传参更新 python some.py a b c -p=a --list=bb 传参有两种方式 a) string type
     > let params = "a b c -p=a --list=bb"
     > jsexecpy.runpath_with_params("some.py",params,callback)

    b) array type

     > let paramslist = ["a","b" ,"c", "-p=a", "--list=bb"]
     > jsexecpy.runpath_with_params("some.py",paramslist,callback)