Issues running global express-generator installation on Ubuntu 16.04

I'm trying to set up express-generator globally on my Ubuntu 16.04 system, but I'm running into some problems. When I run the command to install it, I get a bunch of warnings and errors. Here's what I'm seeing:

1. There's a warning about skipping an optional dependency for fsevents.
2. I'm getting an EACCES error saying I don't have permission to access '/usr/local/lib/node_modules'.
3. The error log suggests running the command as root or Administrator.

I'm not sure what to do next. Is this a common issue? How can I fix it without messing up my system? Any help would be great!

My node version is v4.2.6 and npm version is v4.2.0, if that helps.

hey mate, i had this issue too. the easiest fix is to use nvm (node version manager). it lets u install node n npm without root access. just google ‘install nvm ubuntu’ and follow the steps. then u can do ‘nvm install node’ and ur good to go. no more permission headaches!

The issue you’re encountering is quite common on Ubuntu systems. It’s related to npm’s default global installation directory. Instead of using sudo, which can lead to permission problems, I’d recommend changing npm’s default directory.

Here’s what worked for me:

  1. Create a new directory: mkdir ~/.npm-global
  2. Configure npm to use it: npm config set prefix ‘~/.npm-global’
  3. Add to PATH: export PATH=~/.npm-global/bin:$PATH
  4. Update your profile: echo export PATH=~/.npm-global/bin:$PATH >> ~/.profile
  5. Reload the profile: source ~/.profile

After this, try installing express-generator again without sudo. It should work smoothly. As for the fsevents warning, it’s harmless on non-macOS systems.

Also, consider updating your Node.js and npm versions, which might help avoid compatibility issues with newer packages.

I have experienced a similar problem on Ubuntu and found that the EACCES error happens because npm is trying to install packages in a directory that requires elevated privileges. One remedy is to run the installation command with sudo, such as ‘sudo npm install -g express-generator’. Alternatively, you can change npm’s default directory. This involves creating a new directory in your home folder (for example, ~/.npm-global), configuring npm to use this folder, and updating your system PATH accordingly in your profile. After sourcing your updated profile, you should be able to install express-generator without needing sudo. The warning about fsevents is normal on systems that aren’t running macOS and can be safely ignored.