I have a fresh installation of node.js running plesk onynx (linux centos 6).
I can successfully run the following command which check the version.
/opt/plesk/node/7/bin/npm npm --version
This tells me that npm itself is working.
However I cannot run any of the main commands, ie npm npm install , npm config, npm init and so on.
When I try to run any of the above commands I get the following message:
Usage: npm
where is one of: access, adduser, bin, bugs, c, cache, completion, config, ddp, dedupe, deprecate, dist-tag, docs, edit, explore, get, help, help-search, i, init, install, install-test, it, link, list, ln, login, logout, ls, outdated, owner, pack, ping, prefix, prune, publish, rb, rebuild, repo, restart, root, run, run-script, s, se, search, set, shrinkwrap, star, stars, start, stop, t, team, test, tst, un, uninstall, unpublish, unstar, up, update, v, version, view, whoami
npm -h quick help on npm -l display full usage info npm help search for help on npm help npm involved overview
Specify configs in the ini-formatted file: /root/.npmrc or on the command line via: npm --key value Config info can be viewed via: npm help config
[email protected] /opt/plesk/node/7/lib/node_modules/npm /$ /opt/plesk/node/7/lib/node_modules/npm npm install mongodb7
Any help with this would be greatly appreciated
Everything seems to be working ok. The only thing you should keep in mind that npm is node.js' tool which means that you can utilize it for certain needs connected with the node itself (just like pip on Python or bundler in RoR). So what you can do is following:
Install express.js. It is the very first thing you should have when it comes to be working in node.js. Run:
npm install express-generator -g
this will install express globally which means on the system and not on the app (your problem was appearing because you tried to install node module not in the directory with an application).
Then create a directory where you plan to work with your application and go there:
mkdir yournewapp && cd "$_"
Now when you have a working directory you can use express generator which will create a skeleton for your app. Run following command inside your yournewapp directory (in which you will be since you ran cd yournewapp). You can choose some parameters like using non-default stylesheet engine or ejs instead of jade. For more information use --help parameter with the command:
express
Now when you have a working skeleton go to app.js and specify modules which you're planning to use. After that run:
npm install
and it will install all the modules you mentioned in app.js.
After that you can run your app locally to see if it works:
npm start
voilà.