从项目路径运行节点脚本

时间:2014-12-13 09:37:57

标签: javascript node.js node.js-client

我在win 7上运行,并已将nodeJS安装为路径变量。

我在laravel项目中安装了一个nodeJs模块(pusher),并在添加另一个库时获得了以下文件夹结构:

enter image description here

我想宣传我的server.js文件:

var http = require('http');
http.createServer(function (req, res) {
    res.writeHead(200, {'Content-Type': 'text/plain'});
    res.end('Hello World\n');
}).listen(1337, "127.0.0.1");
console.log('Server running at http://127.0.0.1:1337/');

我尝试导航到我的node_modules文件夹并执行

npm server.js

然而,我只会回来:

$ npm server.js

Usage: npm <command>

where <command> is one of:
    add-user, adduser, apihelp, author, bin, bugs, c, cache,
    completion, config, ddp, dedupe, deprecate, docs, edit,
    explore, faq, find, find-dupes, get, help, help-search,
    home, i, info, init, install, isntall, issues, la, link,
    list, ll, ln, login, ls, outdated, owner, pack, prefix,
    prune, publish, r, rb, rebuild, remove, repo, restart, rm,
    root, run-script, s, se, search, set, show, shrinkwrap,
    star, stars, start, stop, submodule, tag, test, tst, un,
    uninstall, unlink, unpublish, unstar, up, update, v,
    version, view, whoami

npm <cmd> -h     quick help on <cmd>
npm -l           display full usage info
npm faq          commonly asked questions
npm help <term>  search for help on <term>
npm help npm     involved overview

Specify configs in the ini-formatted file:
    C:\Users\User\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@1.3.24 c:\Program Files (x86)\nodejs\node_modules\npm

任何建议我做错了什么?

感谢您的回答!

0 个答案:

没有答案