Node.js - Python-shell



我一直在安装python-shell时遇到一些问题。

警告!我是JavaScript的新手,但是我吃,喝和睡觉python。我很想将Python包括在我正在进行的任何程序中(如果是实用的话)。

我正在创建一些桌面应用程序,并且会喜欢通过一个小HTML,CSS,JavaScript Spice看起来现代。

检查我的节点版本:

C:nodejspy-jstest>npm -v6.4.1

通过NPM安装Python-Shell:

C:nodejspy-jstest>npm install python-shell
npm WARN saveError ENOENT: no such file or directory, open 'C:nodejspy-jstestpackage.json'
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN enoent ENOENT: no such file or directory, open 'C:nodejspy-jstestpackage.json'
npm WARN test No description
npm WARN test No repository field.
npm WARN test No README datanpm WARN test No license field.
python-shell@1.0.6 added 1 package from 1 contributor and audited 1 package in 1.827s found 0 vulnerabilities

NPM测试

C:nodejspy-jstest2>npm test
npm ERR! path C:nodejspy-jstest2package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:nodejspy-jstest2package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in:
npm ERR!     C:UserskurupAppDataRoamingnpm-cache_logs2018-12-19T20_15_56_010Z-debug.log

帮助!:(

您尚未初始化软件包。运行此操作以创建您的package.json文件:

npm init

然后您可以定义测试脚本。

问题之所以发生,是因为您正在尝试使用npm test命令行运行程序。

这是运行特定脚本的NPM命令,在这种情况下,您应该在 package.json 文件中提供的"测试"脚本。由于您根本不创建 package.json ,因此此命令失败。

对于示例,如果您使用 npm init生成 package.json 文件,则将获得此默认的"测试"脚本:

{
  ...
  "scripts": {
    "test": "echo "Error: no test specified" && exit 1"
  }
}

要启动您的程序,您可以使用:

node test.js

,或者您可以在 package.json 中添加一个" start"脚本并使用:

npm start

最新更新