I am trying to install node module "forever" globally on windows machine. So tried installing it with "-g" switch
C:\npm install -g forever
I specifically interested in file "forever.cmd". However this file gets install into the folder
C:\Users\myusername\AppData\Roaming\npm
Well this is not truly global folder. Other users of the same machine cannot access this. Is there any other location forever module gets installed?
I don't think there's a perfect solution for this issue. You could re-install NodeJS, which includes NPM, but install it to a global folder like your system folder (installation instructions here). However, this will require administrator access which will make it potentially unsafe and a pain to use.
I would suggest just making a shortcut, alias, or adding the path to the environment variables for the user in question. That way when you do "forever start" in one user account you can do "forever list" in a different user account.
Good luck.
Related
I work in a big organisation as UX designer. I have basic programming knowledge. I've been trying for ways to install node / npm on macOS without admin rights with no luck.
I've tried all the methods described here
https://gist.github.com/isaacs/579814
but all of them require using sudo or make which I cannot use
I've also downloaded the installer from nodejs.org and, unpack the file with pkgutil but when I run tar on the payloads they are copied to usr/local/bin/includes/node then I try to change the path in the host file but I need admin password to save.
I thought that this would be as easy as doing it on a Windows machine but it's not.
I am working on Windows Server 2012 R2, but external internet connection is restricted in my Org. So i can not install any NPM packages on server directly.
I want to install pm2 OR forever packages globally so that all the user profiles(admin and users) can access that from any directory.
Please guide me in this case.
From another pc with internet connection, you can download the source code from github. For example, for pm2 it is : https://github.com/Unitech/pm2
After downloading the source code, you need to look into the package.json file and download all the dependency source code too. ( One easy way to do all of above is to use npm to fetch pm2 in a local directory then copy the pm2 along with all dependencies to a USB)
Transfer files into a directory of your server workstation using USB or any other suitable means.
Add the pm2/bin directory to your PATH.
Test with pm2 -v from command line to ensure PATH addition is correct.
I suipidly ran this script to stop having to use sudo on npm -g commands and now my node_modules are located at:
/Users/myusername/.npm-packages/lib/node_modules
when trying to run a commands i.e yo bower i get -bash: bower: command not found
Do I need to link this directory to the usr/bin?
In trying to sort this out I have run lots of commands and created symbolic links, I feel like my system is a real mess and I cannot really see what is going on? Help to ensure my system is clean would be really helpful.
Generally, it's a good idea to ensure that you do not need admin rights to run npm commands. The problem you're having, is that the directory where npm now installs its commmands (/Users/myusername/.npm-packges/bin) is not in your PATH. Your PATH is a list of directories where your shell searches for the commands you type.
You can add the directory to your path by adding the following line to the .bashrc file in your home directory (create it if it doesn't exist).
export PATH="${PATH}:/Users/myusername/.npm-packages/bin"
Open a new terminal, and bower should work again.
As an additional tip, I believe you're running on OS X? When installing Node.js using Homebrew, it is automatically installed in a proper way (no sudo needed to install packages globally and they will just work). Next time you're installing Node.js (or something else), Homebrew might be worth a try.
I'm trying to put together a development environment and npm is causing me problems. Here is my scenario:
I have a development machine running Windows and VMWare Player. I have a Ubuntu Server VM (no UI) which is configured with Apache, PHP, NodeJS etc. As the VM has no UI I want to use the host OS for development. I set up a shared directory which in the VM is accessed as /mnt/hgfs/source/<project name>.
The problem comes when I attempt to run npm install within this directory. I see a lot of errors like Error: UNKNOWN, symlink '../requirejs/bin/r.js'. I know that my package.json file is OK because if I copy all files out of the share and into a regular unix directory (/var/www/<project name>) npm install works fine. So npm has a problem installing modules in the shared directory.
I thought I could get around this by installing the node packages globally but, for whatever reason, the GruntJS enthusiasts don't like that and it must be present locally. I then tried to create an npm link from global to local but that just results in a new error: Error: May not delete: /usr/lib/node_modules/grunt. I have full permissions on the /usr/lib/node_modules directory and all sub-directories.
I really don't want to write the entire project using a command-line text editor in the VM but it looks like I cannot have my code-base in a directory available to both the host and guest OS through VMWare.
I would very much appreciate any suggestions on how to either 1) allow npm modules to be installed in my shared directory, 2) run Grunt globally, or 3) solve the npm link error I'm seeing.
EDIT: Shortly after posting this I realised the fundamental issue here - it's not possible to create symbolic links within a VM shared directory when the host OS is Windows. As npm install uses symlinks by default it didn't work, and this is why the accepted solution does work.
Try the following:
npm install --no-bin-links
Grunt should be local since the plugins and gruntfile.js may require a certain version of Grunt in order to run your tasks. If another developer would like to run your tasks, they could just issue an npm install and they are set. (See this for more info.) grunt-cli is global which is used to run the local version of grunt
I am trying to start an angular web app with yeoman but I get permission issue when trying to install the new generator. I can bypass and install generator with sudo but then I get the permission errors when running
**yo** angular
I deduce its because its trying to access npm modules that are global which the current user doesnt have permissions for, and I cant run Yo with sudo. I have done a lot of google searches and they all involve some type of hack with the NODE_PATH in the .bashrc or moving the node modules to the home directory. Has anyone found a simple solution for this issue.
Below is my problem in screenshots:
yo installs fine
when i try to install the generator without sudo complains..
install with sudo passes.
then finally when I try to run yo angular it breaks.. I believe its because yo runs as user and I have installed everything with sudo privileges. How can I get past this?
The reason it breaks, I guess, is because the whole directory tree was created as super-user.
The hacks you mentioned about using NODE_PATH and the home directory are not hacks. They exist for this same very reason. To tell node where to look for packages. And .bashrc is the place where you are supposed to change this kind shell variables.
Say you added ~/.node_modules to you NODE_PATH, then you can install all "global" in there. You could also change the permissions on /usr/local. But on linux world that is not recommended.
I also strongly recommend in not using global install with npm. Using -g and npm link is handy when developing but you shouldn't count on them. You can introduce subtle bugs in your code when you forget to add a package on you package.json but it is installed globally.
Instead of installing it globally, you can find all the packages executable on ./node_modules/.bin/ directory.
But lets say you don't want to be typing ./node_modules/.bin/yo all the time, you could create an alias on your .bashrc.
alias yo="$PWD/node_modules/.bin/yo"
and it would work like expected, and if there is no yo package installed, you get an error.