Edward
Edward

Reputation: 4651

How to install npm packages to current working directory?

I want to install coffee-script to my current working directory. Therefore I run:

npm install coffee-script

Unfortunately an error is thrown

npm ERR! Error: EACCES, symlink '../coffee-script/bin/coffee'
npm ERR!  { [Error: EACCES, symlink '../coffee-script/bin/coffee'] errno: 3, code: 'EACCES', path: '../coffee-script/bin/coffee' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! System Linux 3.16.0-30-generic
npm ERR! command "/usr/bin/nodejs" "/usr/bin/npm" "install" "coffee-script"
npm ERR! cwd /home/username/git/project
npm ERR! node -v v0.10.25
npm ERR! npm -v 1.4.21
npm ERR! path ../coffee-script/bin/coffee
npm ERR! code EACCES
npm ERR! errno 3
npm ERR! stack Error: EACCES, symlink '../coffee-script/bin/coffee'
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/username/git/project/npm-debug.log
npm ERR! not ok code 0

I don't see, why I have to run npm as admin, since I don't want to install it globally,...

When I run sudo npm install coffee-script, coffee-script is installed to my home directory (~/node_modules/coffee-script) and not to the current working directory.

I installed npm from the Ubuntu 14.10 repositories. Additionally I installed the package nodejs-legacy.

The output of the npm-debug.log is:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/nodejs', '/usr/bin/npm', 'install', 'coffee-script' ]
2 info using [email protected]
3 info using [email protected]
4 verbose config Skipping project config: /home/username/.npmrc. (matches userconfig)
5 verbose cache add [ 'coffee-script', null ]
6 verbose cache add name=undefined spec="coffee-script" args=["coffee-script",null]
7 verbose parsed url { protocol: null,
7 verbose parsed url   slashes: null,
7 verbose parsed url   auth: null,
7 verbose parsed url   host: null,
7 verbose parsed url   port: null,
7 verbose parsed url   hostname: null,
7 verbose parsed url   hash: null,
7 verbose parsed url   search: null,
7 verbose parsed url   query: null,
7 verbose parsed url   pathname: 'coffee-script',
7 verbose parsed url   path: 'coffee-script',
7 verbose parsed url   href: 'coffee-script' }
8 silly lockFile ab358269-coffee-script coffee-script
9 verbose lock coffee-script /home/username/.npm/ab358269-coffee-script.lock
10 silly lockFile ab358269-coffee-script coffee-script
11 silly lockFile ab358269-coffee-script coffee-script
12 verbose addNamed [ 'coffee-script', '' ]
13 verbose addNamed [ null, '*' ]
14 silly lockFile 53951495-coffee-script coffee-script@
15 verbose lock coffee-script@ /home/username/.npm/53951495-coffee-script.lock
16 silly addNameRange { name: 'coffee-script', range: '*', hasData: false }
17 verbose request where is /coffee-script
18 verbose request registry https://registry.npmjs.org/
19 verbose request id abb6339315a81c84
20 verbose url raw /coffee-script
21 verbose url resolving [ 'https://registry.npmjs.org/', './coffee-script' ]
22 verbose url resolved https://registry.npmjs.org/coffee-script
23 verbose request where is https://registry.npmjs.org/coffee-script
24 info trying registry request attempt 1 at 14:39:35
25 verbose etag "C6XKWMKZT8HLZEMOMC3EPHFEX"
26 http GET https://registry.npmjs.org/coffee-script
27 http 304 https://registry.npmjs.org/coffee-script
28 silly registry.get cb [ 304,
28 silly registry.get   { date: 'Thu, 12 Feb 2015 13:39:36 GMT',
28 silly registry.get     server: 'Apache',
28 silly registry.get     via: '1.1 varnish',
28 silly registry.get     'last-modified': 'Thu, 12 Feb 2015 12:59:26 GMT',
28 silly registry.get     'cache-control': 'max-age=60',
28 silly registry.get     etag: '"C6XKWMKZT8HLZEMOMC3EPHFEX"',
28 silly registry.get     age: '54',
28 silly registry.get     'x-served-by': 'cache-lcy1123-LCY',
28 silly registry.get     'x-cache': 'HIT',
28 silly registry.get     'x-cache-hits': '450',
28 silly registry.get     'x-timer': 'S1423748376.054272,VS0,VE0',
28 silly registry.get     vary: 'Accept',
28 silly registry.get     'content-length': '0',
28 silly registry.get     'keep-alive': 'timeout=10, max=50',
28 silly registry.get     connection: 'Keep-Alive' } ]
29 verbose etag https://registry.npmjs.org/coffee-script from cache
30 silly addNameRange number 2 { name: 'coffee-script', range: '*', hasData: true }
31 silly addNameRange versions [ 'coffee-script',
31 silly addNameRange   [ '0.7.0',
31 silly addNameRange     '0.7.1',
31 silly addNameRange     '0.7.2',
31 silly addNameRange     '0.9.0',
31 silly addNameRange     '0.9.1',
31 silly addNameRange     '0.9.2',
31 silly addNameRange     '0.9.3',
31 silly addNameRange     '0.9.4',
31 silly addNameRange     '0.9.5',
31 silly addNameRange     '0.9.6',
31 silly addNameRange     '1.0.0',
31 silly addNameRange     '1.0.1',
31 silly addNameRange     '1.1.0',
31 silly addNameRange     '1.1.1',
31 silly addNameRange     '1.1.2',
31 silly addNameRange     '1.1.3',
31 silly addNameRange     '1.2.0',
31 silly addNameRange     '1.3.0',
31 silly addNameRange     '1.3.1',
31 silly addNameRange     '1.3.2',
31 silly addNameRange     '1.3.3',
31 silly addNameRange     '1.4.0',
31 silly addNameRange     '1.5.0',
31 silly addNameRange     '1.6.0',
31 silly addNameRange     '1.6.1',
31 silly addNameRange     '1.6.2',
31 silly addNameRange     '1.6.3',
31 silly addNameRange     '1.7.0',
31 silly addNameRange     '1.7.1',
31 silly addNameRange     '1.8.0',
31 silly addNameRange     '1.9.0' ] ]
32 verbose addNamed [ 'coffee-script', '1.9.0' ]
33 verbose addNamed [ '1.9.0', '1.9.0' ]
34 silly lockFile 479ea950-coffee-script-1-9-0 [email protected]
35 verbose lock [email protected] /home/username/.npm/479ea950-coffee-script-1-9-0.lock
36 silly lockFile 479ea950-coffee-script-1-9-0 [email protected]
37 silly lockFile 479ea950-coffee-script-1-9-0 [email protected]
38 silly lockFile 53951495-coffee-script coffee-script@
39 silly lockFile 53951495-coffee-script coffee-script@
40 silly resolved [ { name: 'coffee-script',
40 silly resolved     description: 'Unfancy JavaScript',
40 silly resolved     keywords: [ 'javascript', 'language', 'coffeescript', 'compiler' ],
40 silly resolved     author: { name: 'Jeremy Ashkenas' },
40 silly resolved     version: '1.9.0',
40 silly resolved     license: 'MIT',
40 silly resolved     engines: { node: '>=0.8.0' },
40 silly resolved     directories: { lib: './lib/coffee-script' },
40 silly resolved     main: './lib/coffee-script/coffee-script',
40 silly resolved     bin: { coffee: './bin/coffee', cake: './bin/cake' },
40 silly resolved     preferGlobal: true,
40 silly resolved     scripts:
40 silly resolved      { test: 'node ./bin/cake test',
40 silly resolved        'test-harmony': 'node --harmony ./bin/cake test' },
40 silly resolved     homepage: 'http://coffeescript.org',
40 silly resolved     bugs: { url: 'https://github.com/jashkenas/coffeescript/issues' },
40 silly resolved     repository:
40 silly resolved      { type: 'git',
40 silly resolved        url: 'git://github.com/jashkenas/coffeescript.git' },
40 silly resolved     devDependencies:
40 silly resolved      { 'uglify-js': '~2.2',
40 silly resolved        jison: '>=0.2.0',
40 silly resolved        'highlight.js': '~8.0.0',
40 silly resolved        underscore: '~1.5.2',
40 silly resolved        docco: '~0.6.2' },
40 silly resolved     gitHead: 'f7692c92ce61c277a3f9a38c6bdbe712730d040a',
40 silly resolved     _id: '[email protected]',
40 silly resolved     _shasum: '7492cbbc3f0361cc5d8865aff7237552ff33e1f7',
40 silly resolved     _from: 'coffee-script@',
40 silly resolved     _npmVersion: '1.4.28',
40 silly resolved     _npmUser: { name: 'jashkenas', email: '[email protected]' },
40 silly resolved     maintainers: [ [Object], [Object] ],
40 silly resolved     dist:
40 silly resolved      { shasum: '7492cbbc3f0361cc5d8865aff7237552ff33e1f7',
40 silly resolved        tarball: 'http://registry.npmjs.org/coffee-script/-/coffee-script-1.9.0.tgz' },
40 silly resolved     _resolved: 'https://registry.npmjs.org/coffee-script/-/coffee-script-1.9.0.tgz',
40 silly resolved     readme: 'ERROR: No README data found!' } ]
41 info install [email protected] into /home/username
42 info installOne [email protected]
43 verbose node_modules/coffee-script unbuild
44 info preuninstall [email protected]
45 info uninstall [email protected]
46 verbose true,/home/username/node_modules,/home/username/node_modules unbuild [email protected]
47 verbose /home/username/node_modules/.bin,[object Object] binRoot
48 verbose node_modules/coffee-script unbuild
49 info preuninstall [email protected]
50 info uninstall [email protected]
51 verbose true,/home/username/node_modules,/home/username/node_modules unbuild [email protected]
52 verbose /home/username/node_modules/.bin,[object Object] binRoot
53 error error rolling back Error: EACCES, unlink '/home/username/node_modules/.bin/coffee'
53 error error rolling back  [email protected] { [Error: EACCES, unlink '/home/username/node_modules/.bin/coffee']
53 error error rolling back   errno: 3,
53 error error rolling back   code: 'EACCES',
53 error error rolling back   path: '/home/username/node_modules/.bin/coffee' }
54 error Error: EACCES, unlink '/home/username/node_modules/.bin/coffee'
54 error  { [Error: EACCES, unlink '/home/username/node_modules/.bin/coffee']
54 error   errno: 3,
54 error   code: 'EACCES',
54 error   path: '/home/username/node_modules/.bin/coffee' }
55 error Please try running this command again as root/Administrator.
56 error System Linux 3.16.0-30-generic
57 error command "/usr/bin/nodejs" "/usr/bin/npm" "install" "coffee-script"
58 error cwd /home/username/Desktop/npmtest
59 error node -v v0.10.25
60 error npm -v 1.4.21
61 error path /home/username/node_modules/.bin/coffee
62 error code EACCES
63 error errno 3
64 error stack Error: EACCES, unlink '/home/username/node_modules/.bin/coffee'
65 verbose exit [ 3, true ]

Upvotes: 1

Views: 847

Answers (2)

Jay
Jay

Reputation: 3515

Try updating your npm to a newer version:

[sudo] npm install -g npm

And install coffee-script module again.

Also, make sure you don't have a global: true set in your ~/.npmrc file.

Upvotes: 1

siavolt
siavolt

Reputation: 7077

Try before

install nmp cache clean

and after

npm install coffee-script

Upvotes: 0

Related Questions