skip to Main Content

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

2

Answers


  1. 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:

    1. 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).

    2. Then create a directory where you plan to work with your application and go there:

      mkdir yournewapp && cd "$_"
      
    3. 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  
      
    4. 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.

    5. After that you can run your app locally to see if it works:

      npm start
      

    voilà.

    Login or Signup to reply.
  2. I don’t know why you can’t outright use the npm command, but if you use the full path it should work fine. For example:

    ./opt/plesk/node/7/lib/node_modules/npm install npm

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search