简体   繁体   English

Node.js-Python外壳

[英]Node.js - Python-shell

I've been having some issues with installing python-shell. 我在安装python-shell时遇到了一些问题。

WARNING! 警告! I'm a novice at Javascript however I eat, drink and sleep Python. 我是Javascript的新手,但是我吃,喝和睡Python。 I would love to include Python in whatever program I'm working on (if it's practical). 我想将Python包含在我正在开发的任何程序中(如果可行)。

I am creating some desktop applications and would love the make them look modern via a little Html, CSS, Javascript spice. 我正在创建一些桌面应用程序,希望通过一点HTML,CSS和Javascript香料使它们看起来很现代。

Checking my Node version: 检查我的节点版本:

C:\nodejs\py-js\test>npm -v6.4.1

Installing Python-Shell via npm: 通过npm安装Python-Shell:

C:\nodejs\py-js\test>npm install python-shell
npm WARN saveError ENOENT: no such file or directory, open 'C:\nodejs\py-js\test\package.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:\nodejs\py-js\test\package.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 test npm测试

C:\nodejs\py-js\test2>npm test
npm ERR! path C:\nodejs\py-js\test2\package.json
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall open
npm ERR! enoent ENOENT: no such file or directory, open 'C:\nodejs\py-js\test2\package.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:\Users\kurup\AppData\Roaming\npm-cache\_logs\2018-12-19T20_15_56_010Z-debug.log

HELP! 救命! :( :(

You haven't initialized the package. 您尚未初始化程序包。 Run this to create your package.json file: 运行此命令以创建package.json文件:

npm init

Then you can define your test script. 然后,您可以定义您的测试脚本。

The problem occurs because you are trying to run your program with the npm test command line. 发生问题是因为您尝试使用npm test命令行运行程序。

This is the npm command to run a specific script, in this case the "test" script that you should provide in your package.json file. 这是npm命令,用于运行特定的脚本,在这种情况下,您应该在package.json文件中提供“测试”脚本。 Since you do not create a package.json at all, this command fails. 由于根本不创建package.json ,因此此命令失败。

For exemple, if you use npm init to generate a package.json file, you will get this default "test" script: 例如,如果您使用npm init生成package.json文件,则将获得以下默认“测试”脚本:

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

To launch your program, you can use: 要启动程序,可以使用:

node test.js

Or you could add a "start" script in your package.json and use: 或者,您可以在package.json中添加“开始”脚本并使用:

npm start

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM