标签:
参照:http://yeoman.io/codelab/setup.html
1:$npm install --global yo bower grunt-cli
提示以下错误
npm ERR! tar.unpack untar error /home/y/.npm/grunt-cli/0.1.13/package.tgz npm ERR! tar.unpack untar error /home/y/.npm/yo/1.4.6/package.tgz npm ERR! tar.unpack untar error /home/y/.npm/bower/1.4.1/package.tgz npm ERR! Linux 3.13.0-24-generic npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--global" "yo" "bower" "grunt-cli" npm ERR! node v0.12.2 npm ERR! npm v2.7.4 npm ERR! path /usr/local/lib/node_modules/grunt-cli npm ERR! code EACCES npm ERR! errno -13 npm ERR! Error: EACCES, mkdir ‘/usr/local/lib/node_modules/grunt-cli‘ npm ERR! at Error (native) npm ERR! { [Error: EACCES, mkdir ‘/usr/local/lib/node_modules/grunt-cli‘] npm ERR! errno: -13, npm ERR! code: ‘EACCES‘, npm ERR! path: ‘/usr/local/lib/node_modules/grunt-cli‘, npm ERR! fstream_type: ‘Directory‘, npm ERR! fstream_path: ‘/usr/local/lib/node_modules/grunt-cli‘, npm ERR! fstream_class: ‘DirWriter‘, npm ERR! fstream_stack: npm ERR! [ ‘/usr/local/lib/node_modules/npm/node_modules/fstream/lib/dir-writer.js:36:23‘, npm ERR! ‘/usr/local/lib/node_modules/npm/node_modules/mkdirp/index.js:46:53‘, npm ERR! ‘FSReqWrap.oncomplete (fs.js:95:15)‘ ] } npm ERR! npm ERR! Please try running this command again as root/Administrator. npm ERR! Please include the following file with any support request: npm ERR! /home/y/npm-debug.log
解决方法参照:https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md
(1)mkdir "${HOME}/.npm-packages"
(2).bashrc
NPM_PACKAGES="${HOME}/.npm-packages"
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
PATH="$NPM_PACKAGES/bin:$PATH"
unset MANPATH # delete if you already modified MANPATH elsewhere in your config
MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
(3)$HOME/.npmrc
prefix=${HOME}/.npm-packages
2:再次安装:y@y:~$ npm install --global yo bower grunt-cli
提示:npm WARN optional dep failed, continuing uglify-js@~2.3
解决方法:y@y:~$sudo npm cache clean
3:查看npm配置信息
y@y:~$ npm config get prefix
/home/y/.npm-packages
进行安装:y@y:~$ npm install --global yo bower grunt-cli
/home/y/.npm-packages/bin/grunt -> /home/y/.npm-packages/lib/node_modules/grunt-cli/bin/grunt /home/y/.npm-packages/bin/yo -> /home/y/.npm-packages/lib/node_modules/yo/lib/cli.js > yo@1.4.6 postinstall /home/y/.npm-packages/lib/node_modules/yo > yodoctor - Yeoman Doctor Running sanity checks on your system ? Global configuration file is valid ? NODE_PATH matches the npm root ? No .bowerrc file in home directory ? No .yo-rc.json file in home directory Everything looks all right! /home/y/.npm-packages/bin/bower -> /home/y/.npm-packages/lib/node_modules/bower/bin/bower grunt-cli@0.1.13 /home/y/.npm-packages/lib/node_modules/grunt-cli ├── resolve@0.3.1 ├── nopt@1.0.10 (abbrev@1.0.5) └── findup-sync@0.1.3 (lodash@2.4.2, glob@3.2.11) yo@1.4.6 /home/y/.npm-packages/lib/node_modules/yo ├── titleize@1.0.0 ├── array-uniq@1.0.2 ├── figures@1.3.5 ├── user-home@1.1.1 ├── opn@1.0.2 ├── async@0.9.0 ├── cross-spawn@0.2.9 (lru-cache@2.6.2) ├── lodash@3.8.0 ├── yeoman-character@1.0.1 (supports-color@1.3.1) ├── string-length@1.0.0 (strip-ansi@2.0.1) ├── humanize-string@1.0.1 (decamelize@1.0.0) ├── sort-on@1.2.0 (dot-prop@2.0.0) ├── findup@0.1.5 (commander@2.1.0, colors@0.6.2) ├── chalk@1.0.0 (escape-string-regexp@1.0.3, ansi-styles@2.0.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3) ├── update-notifier@0.3.2 (is-npm@1.0.0, latest-version@1.0.0, semver-diff@2.0.0) ├── got@2.9.2 (object-assign@2.0.0, lowercase-keys@1.0.0, is-stream@1.0.1, timed-out@2.0.0, prepend-http@1.0.1, nested-error-stacks@1.0.0, statuses@1.2.1, infinity-agent@2.0.3, read-all-stream@2.1.2, duplexify@3.3.0) ├── root-check@1.0.0 (downgrade-root@1.1.0, sudo-block@1.2.0) ├── npm-keyword@1.1.1 (registry-url@3.0.3) ├── package-json@1.1.0 (registry-url@3.0.3) ├── fullname@1.1.0 (npmconf@2.1.1) ├── yosay@1.0.3 (ansi-regex@1.1.1, ansi-styles@2.0.1, strip-ansi@2.0.1, word-wrap@1.0.3, pad-component@0.0.1, taketalk@1.0.0, minimist@1.1.1) ├── configstore@0.3.2 (object-assign@2.0.0, xdg-basedir@1.0.1, osenv@0.1.0, graceful-fs@3.0.6, uuid@2.0.1, mkdirp@0.5.0, js-yaml@3.3.0) ├── yeoman-environment@1.2.5 (escape-string-regexp@1.0.3, log-symbols@1.0.2, untildify@2.0.0, diff@1.4.0, text-table@0.2.0, debug@2.1.3, globby@1.2.0, grouped-queue@0.3.0, mem-fs@1.1.0) ├── meow@3.1.0 (object-assign@2.0.0, minimist@1.1.1, camelcase-keys@1.0.0, indent-string@1.2.1) ├── yeoman-doctor@1.3.2 (object-values@1.0.0, log-symbols@1.0.2, each-async@1.1.1, twig@0.7.2) ├── insight@0.5.3 (object-assign@2.0.0, lodash.debounce@3.0.3, tough-cookie@0.12.1, os-name@1.0.3, request@2.55.0) └── inquirer@0.8.3 (ansi-regex@1.1.1, cli-width@1.0.1, through@2.3.7, readline2@0.1.1, rx@2.5.2) bower@1.4.1 /home/y/.npm-packages/lib/node_modules/bower ├── is-root@1.0.0 ├── junk@1.0.1 ├── stringify-object@1.0.1 ├── abbrev@1.0.5 ├── user-home@1.1.1 ├── which@1.0.9 ├── chmodr@0.1.0 ├── rimraf@2.3.3 ├── archy@1.0.0 ├── opn@1.0.2 ├── bower-logger@0.2.2 ├── bower-endpoint-parser@0.2.2 ├── graceful-fs@3.0.6 ├── lockfile@1.0.0 ├── lru-cache@2.6.2 ├── nopt@3.0.1 ├── retry@0.6.1 ├── tmp@0.0.24 ├── q@1.3.0 ├── semver@2.3.2 ├── fstream@1.0.5 (inherits@2.0.1) ├── mout@0.11.0 ├── p-throttler@0.1.1 (q@0.9.7) ├── request-progress@0.3.1 (throttleit@0.0.2) ├── bower-json@0.4.0 (intersect@0.0.3, deep-extend@0.2.11, graceful-fs@2.0.3) ├── shell-quote@1.4.3 (array-filter@0.0.1, array-reduce@0.0.0, array-map@0.0.0, jsonify@0.0.0) ├── promptly@0.2.0 (read@1.0.5) ├── chalk@1.0.0 (escape-string-regexp@1.0.3, ansi-styles@2.0.1, supports-color@1.3.1, strip-ansi@2.0.1, has-ansi@1.0.3) ├── github@0.2.4 (mime@1.3.4) ├── fstream-ignore@1.0.2 (inherits@2.0.1, minimatch@2.0.7) ├── glob@4.5.3 (inherits@2.0.1, inflight@1.0.4, once@1.3.2, minimatch@2.0.7) ├── tar-fs@1.5.0 (pump@1.0.0, tar-stream@1.1.4) ├── decompress-zip@0.1.0 (mkpath@0.1.0, touch@0.0.3, readable-stream@1.1.13, binary@0.3.0) ├── mkdirp@0.5.0 (minimist@0.0.8) ├── bower-config@0.6.1 (osenv@0.0.3, graceful-fs@2.0.3, mout@0.9.1, optimist@0.6.1) ├── update-notifier@0.3.2 (is-npm@1.0.0, string-length@1.0.0, semver-diff@2.0.0, latest-version@1.0.0) ├── insight@0.5.3 (object-assign@2.0.0, async@0.9.0, lodash.debounce@3.0.3, tough-cookie@0.12.1, os-name@1.0.3) ├── cardinal@0.4.4 (ansicolors@0.2.1, redeyed@0.4.4) ├── request@2.53.0 (caseless@0.9.0, json-stringify-safe@5.0.0, aws-sign2@0.5.0, forever-agent@0.5.2, stringstream@0.0.4, oauth-sign@0.6.0, tunnel-agent@0.4.0, isstream@0.1.2, node-uuid@1.4.3, qs@2.3.3, form-data@0.2.0, bl@0.9.4, tough-cookie@1.1.0, combined-stream@0.0.7, mime-types@2.0.11, http-signature@0.10.1, hawk@2.3.1) ├── bower-registry-client@0.3.0 (graceful-fs@2.0.3, request-replay@0.2.0, rimraf@2.2.8, lru-cache@2.3.1, async@0.2.10, mkdirp@0.3.5, request@2.51.0) ├── handlebars@2.0.0 (optimist@0.3.7, uglify-js@2.3.6) ├── configstore@0.3.2 (object-assign@2.0.0, xdg-basedir@1.0.1, osenv@0.1.0, uuid@2.0.1, js-yaml@3.3.0) └── inquirer@0.8.0 (figures@1.3.5, ansi-regex@1.1.1, mute-stream@0.0.4, through@2.3.7, lodash@2.4.2, readline2@0.1.1, rx@2.5.2, chalk@0.5.1, cli-color@0.3.3)
4:检查是否安装成功
y@y:~$ yo --version && bower --version && grunt --version 1.4.6 1.4.1 grunt-cli v0.1.13
标签:
原文地址:http://www.cnblogs.com/yshyee/p/4487429.html