Opened 13 years ago

Closed 13 years ago

#33175 closed defect (invalid)

NPM doesn't install packages in the appropriate location

Reported by: conradwt (Conrad Taylor) Owned by: ci42
Priority: Normal Milestone:
Component: ports Version: 2.0.3
Keywords: Cc: ryandesignmacports.org
Port: npm

Description

npm requires one to install packages using sudo. For example,

sudo npm install <package-name>

Otherwise, one will receive the following message:

$ npm install pubnub
npm http GET https://registry.npmjs.org/pubnub
npm http 304 https://registry.npmjs.org/pubnub
npm ERR! error installing pubnub@3.1.6
npm ERR! error rolling back pubnub@3.1.6 Error: EACCES, permission denied '/opt/local/lib/node_modules/pubnub/package.json'

npm ERR! Error: EACCES, permission denied '/opt/local/lib/node_modules/pubnub/package.json'
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.
npm ERR! 
npm ERR! System Darwin 11.3.0
npm ERR! command "node" "/opt/local/bin/npm" "install" "pubnub"
npm ERR! cwd /Users/conradwt/nodejs.dir/examples/pubnub-example
npm ERR! node -v v0.6.10
npm ERR! npm -v 1.1.0-2
npm ERR! path /opt/local/lib/node_modules/pubnub/package.json
npm ERR! code EACCES
npm ERR! message EACCES, permission denied '/opt/local/lib/node_modules/pubnub/package.json'
npm ERR! errno {}
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /Users/conradwt/nodejs.dir/examples/pubnub-example/npm-debug.log
npm not ok

Furthermore, when I do not want to install packages globally but within the project directory. For example, the package is installed in

/opt/local/lib/node_modules/pubnub

instead of the current working directory.

Change History (5)

comment:1 Changed 13 years ago by ryandesign (Ryan Carsten Schmidt)

Cc: ryandesignmacports.org added; ciserlohn@… removed
Owner: changed from macports-tickets@… to ciserlohn@…

I've never seen the behavior you describe. npm works fine for me. I've never tried to install packages globally, since it is not recommended to do so. I've always only installed packages locally.

comment:2 Changed 13 years ago by ci42

I can't reproduce the behaviour you described - neither using version 1.1.0-2 nor using the current version 1.1.0-3_1. When looking at the output you provided I noticed that npm tried to install the package pubnub globally, even though you didn't specified the '-g'/'--globally' option. Perhaps you have enabled global installs by default? Please check your configuration:

$ npm get global

The output should be:

false

If its

true

change you configuration. Use

npm help config

to get an overview of the various configuration sources.

Apart from that using sudo is mandatory if you install packages globally as it potentially affect all users on your system.

comment:3 Changed 13 years ago by stephen@…

Hi Conrad!

The following was successful for me:

mkdir my-app
cd my-app
npm install pubnub

comment:4 Changed 13 years ago by conradwt (Conrad Taylor)

OK, I'm seeing the following when I query the value of the global value:

$ npm get global
true

Now, the issue was the following which I didn't manually create and/or edit myself:

$ npm config list ; cli configs

; userconfig /Users/conradwt/.npmrc global = true

; globalconfig /opt/local/etc/npmrc

; node install prefix = undefined ; node bin location = /opt/local/bin/node ; cwd = /Users/conradwt/pubnub ; HOME = /Users/conradwt ; 'npm config ls -l' to show all defaults. }}}

Next, I'm seeing the following:

$ npm list -g
/opt/local/lib
├── coffee-script@1.2.0 
├─┬ js2coffee@0.1.3 
│ ├── coffee-script@1.2.0 
│ └── underscore@1.3.0 
└─┬ npm@1.1.0-2 
  ├── abbrev@1.0.3 
  ├── block-stream@0.0.4 
  ├── fast-list@1.0.2 
  ├── fstream@0.1.11 
  ├── graceful-fs@1.1.2 
  ├── inherits@1.0.0 
  ├── ini@1.0.2 
  ├── lru-cache@1.0.5 
  ├── minimatch@0.1.3 
  ├── mkdirp@0.1.0 
  ├── node-uuid@1.3.3 
  ├── nopt@1.0.10 
  ├── proto-list@1.0.0 
  ├── read@0.0.1 
  ├── request@2.9.3 
  ├── rimraf@1.0.9 
  ├── semver@1.0.13 
  ├── slide@1.1.3 
  ├── tar@0.1.12 
  └── which@1.0.2

Finally, when I'm in the home directory, I get the following result and things are back to normal:

$ npm list
/Users/conradwt
(empty)

comment:5 Changed 13 years ago by ci42

Resolution: invalid
Status: newclosed
Note: See TracTickets for help on using tickets.