简体   繁体   English

运行 Primewire NPM 依赖项

[英]Run Primewire NPM Dependency

I'm looking to run and execute this code.我正在寻找运行并执行此代码。 https://github.com/Evan-Goode/primewire?files=1 I'm not familiar with JavaScript. https://github.com/Evan-Goode/primewire?files=1我不熟悉 JavaScript。 I know you have to call if from an html file but I'm not sure if I have to point to where it is located.我知道您必须从 html 文件中调用 if,但我不确定是否必须指向它所在的位置。 I installed the npm library and have the node_modules folder but I'm not sure how to run and execute this code to get the result.我安装了 npm 库并有 node_modules 文件夹,但我不确定如何运行和执行此代码以获得结果。 If anyone could help explain this to me it would be greatly appreciated.如果有人能帮助我解释这一点,将不胜感激。 Thanks谢谢

var primewire = require('primewire');

function display(err, links, id) {
 if (err) {
    return console.error(err.stack);
}

console.log('%d total links found for "%s".', links.length, id);
console.log('Watch now at ' + links[0]);
}

primewire({
title: 'The Simpsons',
year: 1989,
season: 1,
episode: 2
}, display);

// Using an ID instead of title/year will result in less page load time.
primewire({
id: '4131', // http://www.primewire.ag/watch-4131-The-Simpsons
season: 1,
episode: 4
}, display);

primewire({
title: 'Saw',
year: 2004
}, display);

primewire({
id: '1672' // http://www.primewire.ag/watch-1672-Saw-II
}, display);

You appear to have linked to a repository containing an NPM module.您似乎已链接到包含 NPM 模块的存储库。

As the README in the project states, you can install the module to your current working project by running:正如项目中的README所述,您可以通过运行将模块安装到当前工作项目中:

npm install primewire

which would then allow you to add it as a dependency to your project:这将允许您将其作为依赖项添加到您的项目中:

var primewire = require('primewire');

You typically never run code from your node_modules folder, but rather treat it as a dependency consumed in your project through require or static linking.您通常从不运行node_modules文件夹中的代码,而是将其视为通过require或静态链接在项目中消耗的依赖项。 (Modeling functionality from the documentation in the repo) (来自 repo 中的文档的建模功能)

That said, they appear to provide you some examples, so you could clone the repo and just run node against them.也就是说,它们似乎为您提供了一些示例,因此您可以clone库并针对它们运行node

It sounds like you might benefit from taking pause and learning some NodeJS fundamentals, like the typical workflow .听起来您可能会从暂停并学习一些 NodeJS 基础知识中受益,例如典型的工作流程

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

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