今天我一直在爲這個問題苦苦掙扎,並且無法弄清楚問題所在 - 不幸的是Google並沒有多大的幫助。在節點上安裝Karma時出錯 - 檢索當前目錄時出錯 - 在OSX上
我想要遵循AngularJS教程,但無法安裝Karma。每次嘗試時,我都會收到一條錯誤消息:「檢索當前目錄時出錯:getcwd:無法訪問父目錄:權限被拒絕」。
這裏的副本輸出在bash:
Barts-MacBook-Pro:~ bart$ sudo npm install -g karma
Password:
npm http GET https://registry.npmjs.org/karma
npm http GET https://registry.npmjs.org/karma
npm http 200 https://registry.npmjs.org/karma
npm http GET https://registry.npmjs.org/karma/-/karma-0.8.5.tgz
npm http 200 https://registry.npmjs.org/karma/-/karma-0.8.5.tgz
npm http GET https://registry.npmjs.org/chokidar
npm http GET https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/glob
npm http GET https://registry.npmjs.org/socket.io
npm http GET https://registry.npmjs.org/coffee-script
npm http GET https://registry.npmjs.org/xmlbuilder/0.4.2
npm http GET https://registry.npmjs.org/optimist/0.3.5
npm http GET https://registry.npmjs.org/colors/0.6.0-1
npm http GET https://registry.npmjs.org/LiveScript/1.0.1
npm http GET https://registry.npmjs.org/dateformat/1.0.2-1.2.3
npm http GET https://registry.npmjs.org/mime
npm http GET https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/istanbul/0.1.22
npm http GET https://registry.npmjs.org/pause/0.0.1
npm http GET https://registry.npmjs.org/growly
npm http GET https://registry.npmjs.org/q
npm http GET https://registry.npmjs.org/lodash
npm http GET https://registry.npmjs.org/log4js
npm http GET https://registry.npmjs.org/http-proxy
npm http 304 https://registry.npmjs.org/chokidar
npm http 304 https://registry.npmjs.org/xmlbuilder/0.4.2
npm http 200 https://registry.npmjs.org/optimist/0.3.5
npm http GET https://registry.npmjs.org/optimist/-/optimist-0.3.5.tgz
npm http 200 https://registry.npmjs.org/colors/0.6.0-1
npm http GET https://registry.npmjs.org/colors/-/colors-0.6.0-1.tgz
npm http 304 https://registry.npmjs.org/LiveScript/1.0.1
npm http 304 https://registry.npmjs.org/dateformat/1.0.2-1.2.3
npm http 304 https://registry.npmjs.org/mime
npm http 304 https://registry.npmjs.org/rimraf
npm http 200 https://registry.npmjs.org/coffee-script
npm http 200 https://registry.npmjs.org/colors/-/colors-0.6.0-1.tgz
npm http 304 https://registry.npmjs.org/pause/0.0.1
npm http 304 https://registry.npmjs.org/growly
npm http 304 https://registry.npmjs.org/istanbul/0.1.22
npm http 200 https://registry.npmjs.org/minimatch
npm http GET https://registry.npmjs.org/minimatch/-/minimatch-0.2.12.tgz
npm http 304 https://registry.npmjs.org/log4js
npm http 200 https://registry.npmjs.org/optimist/-/optimist-0.3.5.tgz
npm http 200 https://registry.npmjs.org/minimatch/-/minimatch-0.2.12.tgz
npm http 200 https://registry.npmjs.org/glob
npm http 200 https://registry.npmjs.org/socket.io
npm http 200 https://registry.npmjs.org/http-proxy
npm http GET https://registry.npmjs.org/http-proxy/-/http-proxy-0.10.2.tgz
npm http 200 https://registry.npmjs.org/q
npm http GET https://registry.npmjs.org/q/-/q-0.9.3.tgz
npm http 200 https://registry.npmjs.org/lodash
npm http 200 https://registry.npmjs.org/http-proxy/-/http-proxy-0.10.2.tgz
npm http 200 https://registry.npmjs.org/q/-/q-0.9.3.tgz
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/lru-cache
npm http GET https://registry.npmjs.org/sigmund
npm http GET https://registry.npmjs.org/graceful-fs
npm http GET https://registry.npmjs.org/inherits
npm http GET https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/socket.io-client/0.9.11
npm http GET https://registry.npmjs.org/policyfile/0.0.4
npm http GET https://registry.npmjs.org/base64id/0.1.0
npm http GET https://registry.npmjs.org/redis/0.7.3
npm http GET https://registry.npmjs.org/prelude-ls
npm http GET https://registry.npmjs.org/async/0.1.15
npm http GET https://registry.npmjs.org/dequeue/1.0.3
npm http GET https://registry.npmjs.org/semver
npm http GET https://registry.npmjs.org/readable-stream
npm http GET https://registry.npmjs.org/mkdirp
npm http GET https://registry.npmjs.org/esprima
npm http GET https://registry.npmjs.org/handlebars
npm http GET https://registry.npmjs.org/escodegen
npm http GET https://registry.npmjs.org/fileset
npm http GET https://registry.npmjs.org/which
npm http GET https://registry.npmjs.org/nopt
npm http GET https://registry.npmjs.org/wordwrap
npm http GET https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/abbrev
npm http GET https://registry.npmjs.org/pkginfo
npm http GET https://registry.npmjs.org/utile
npm http 304 https://registry.npmjs.org/inherits
npm http 304 https://registry.npmjs.org/sigmund
npm http 304 https://registry.npmjs.org/graceful-fs
npm http 304 https://registry.npmjs.org/graceful-fs
npm http 304 https://registry.npmjs.org/wordwrap
npm http 304 https://registry.npmjs.org/socket.io-client/0.9.11
npm http 304 https://registry.npmjs.org/policyfile/0.0.4
npm http 304 https://registry.npmjs.org/base64id/0.1.0
npm http 304 https://registry.npmjs.org/redis/0.7.3
npm http 304 https://registry.npmjs.org/prelude-ls
npm http 304 https://registry.npmjs.org/dequeue/1.0.3
npm http 200 https://registry.npmjs.org/async/0.1.15
npm http GET https://registry.npmjs.org/async/-/async-0.1.15.tgz
npm http GET https://registry.npmjs.org/active-x-obfuscator/0.0.1
npm http GET https://registry.npmjs.org/uglify-js/1.2.5
npm http GET https://registry.npmjs.org/xmlhttprequest/1.4.2
npm http GET https://registry.npmjs.org/ws
npm http 304 https://registry.npmjs.org/semver
npm http 304 https://registry.npmjs.org/readable-stream
npm http 304 https://registry.npmjs.org/mkdirp
npm http 304 https://registry.npmjs.org/esprima
npm http 200 https://registry.npmjs.org/lru-cache
npm http 304 https://registry.npmjs.org/handlebars
npm http 304 https://registry.npmjs.org/fileset
npm http 304 https://registry.npmjs.org/nopt
npm http 304 https://registry.npmjs.org/wordwrap
npm http 304 https://registry.npmjs.org/abbrev
npm http 304 https://registry.npmjs.org/pkginfo
npm http 304 https://registry.npmjs.org/which
npm http 304 https://registry.npmjs.org/utile
npm http 304 https://registry.npmjs.org/active-x-obfuscator/0.0.1
npm http GET https://registry.npmjs.org/rimraf
npm http GET https://registry.npmjs.org/deep-equal
npm http GET https://registry.npmjs.org/i
npm http GET https://registry.npmjs.org/ncp
npm http 200 https://registry.npmjs.org/uglify-js/1.2.5
npm http GET https://registry.npmjs.org/uglify-js/-/uglify-js-1.2.5.tgz
npm http 304 https://registry.npmjs.org/xmlhttprequest/1.4.2
npm http 200 https://registry.npmjs.org/async/-/async-0.1.15.tgz
npm http 304 https://registry.npmjs.org/rimraf
npm http 304 https://registry.npmjs.org/deep-equal
npm http 304 https://registry.npmjs.org/i
npm http 304 https://registry.npmjs.org/ncp
npm http 200 https://registry.npmjs.org/escodegen
npm http GET https://registry.npmjs.org/escodegen/-/escodegen-0.0.21.tgz
npm http 200 https://registry.npmjs.org/ws
npm http 200 https://registry.npmjs.org/uglify-js/-/uglify-js-1.2.5.tgz
npm http 200 https://registry.npmjs.org/escodegen/-/escodegen-0.0.21.tgz
npm http 200 https://registry.npmjs.org/async
npm http GET https://registry.npmjs.org/esprima
npm http GET https://registry.npmjs.org/estraverse
npm http GET https://registry.npmjs.org/source-map
npm http GET https://registry.npmjs.org/uglify-js
npm http 304 https://registry.npmjs.org/source-map
npm http 304 https://registry.npmjs.org/estraverse
npm http 304 https://registry.npmjs.org/esprima
npm http GET https://registry.npmjs.org/amdefine
npm http 200 https://registry.npmjs.org/uglify-js
npm http 304 https://registry.npmjs.org/amdefine
npm http GET https://registry.npmjs.org/zeparser/0.0.5
npm http GET https://registry.npmjs.org/commander
npm http GET https://registry.npmjs.org/tinycolor
npm http GET https://registry.npmjs.org/options
npm http 304 https://registry.npmjs.org/zeparser/0.0.5
npm http 304 https://registry.npmjs.org/tinycolor
npm http 304 https://registry.npmjs.org/options
npm http 200 https://registry.npmjs.org/commander
> [email protected] install /usr/local/lib/node_modules/karma/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
shell-init: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
job-working-directory: error retrieving current directory: getcwd: cannot access parent directories: Permission denied
/usr/local/bin/karma -> /usr/local/lib/node_modules/karma/bin/karma
[email protected] /usr/local/lib/node_modules/karma
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected]
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected])
├── [email protected] ([email protected], [email protected])
├── [email protected] ([email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected], [email protected])
└── [email protected] ([email protected], [email protected], [email protected], [email protected])
Barts-MacBook-Pro:~ bart$
我跑節點0.10.4,順便說一句。
不幸的是,我現在有點虧了,所以任何援助將感激地收到!
非常感謝,
巴特
編輯 - 2017年1月
我原來問過這個問題w.r.t. OSX Mountain Lion,但我在新版本的OSX上遇到過類似的問題。我在下面編輯了我的答案,以包含我認爲對於所有版本的OSX更好的解決方案。