sindresorhus / guides

A collection of succinct guides - Public Domain
2.47k stars 458 forks source link

Lost all my npm packages #38

Closed asimkt closed 8 years ago

asimkt commented 8 years ago

I've tried to remove sudo for installing npm_packages using https://github.com/glenpike/npm-g_nosudo.

I've used wget.

And I think it removed all my packages and reinstalled it. (I suppose).

And in the end I got this in the terminal:


....
- titleize@1.0.0 node_modules/yo/node_modules/titleize
- update-notifier@0.6.3 node_modules/yo/node_modules/update-notifier
- yeoman-character@1.1.0 node_modules/yo/node_modules/yeoman-character
- yeoman-doctor@2.1.0 node_modules/yo/node_modules/yeoman-doctor
- yeoman-environment@1.6.3 node_modules/yo/node_modules/yeoman-environment
- yosay@1.2.0 node_modules/yo/node_modules/yosay
- yo@1.8.4 node_modules/yo
sh: 74: [: npm: unexpected operator
sh: 77: [: npm: unexpected operator
npm ERR! fetch failed https://registry.npmjs.org/i/-/i-0.3.2.tgz
npm WARN retry will retry, error on last attempt: Error: fetch failed with status code 504
npm ERR! fetch failed https://registry.npmjs.org/i/-/i-0.3.2.tgz
npm WARN retry will retry, error on last attempt: Error: getaddrinfo EAI_AGAIN registry.npmjs.org:443
npm ERR! fetch failed https://registry.npmjs.org/i/-/i-0.3.2.tgz
npm ERR! Linux 3.19.0-66-generic
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "-g" "install" "bower@1.7.9" "cordova@4.3.0" "generator-angular@0.15.1" "generator-fountain-webapp@0.6.0" "generator-gulp-angular@1.0.2" "generator-karma@2.0.0" "grunt-cli@1.2.0" "gulp@3.9.0" "ionic@1.3.14" "n@2.1.0" "netlify-cli@1.0.2" "yo@1.8.4"
npm ERR! node v5.4.1
npm ERR! npm  v3.10.5

npm ERR! fetch failed with status code 504
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/asim/npm-debug.log

Invalid choice

You may need to add the following to your ~/.bashrc / .zshrc file(s)

export NPM_PACKAGES="npm"
export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}"
export PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath`
# command
unset MANPATH  # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"

export NPM_PACKAGES="config"
export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}"
export PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath`
# command
unset MANPATH  # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"

export NPM_PACKAGES="set"
export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}"
export PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath`
# command
unset MANPATH  # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"

export NPM_PACKAGES="prefix"
export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}"
export PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath`
# command
unset MANPATH  # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"

export NPM_PACKAGES="$npmdir/.npm-packages"
export NODE_PATH="$NPM_PACKAGES/lib/node_modules${NODE_PATH:+:$NODE_PATH}"
export PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath`
# command
unset MANPATH  # delete if you already modified MANPATH elsewhere in your config
export MANPATH="$NPM_PACKAGES/share/man:$(manpath)"

Done - current package list:

/usr/local/lib
`-- npm@3.10.5

Then I copied the code from export NPM_PACKAGES="npm" to export MANPATH="$NPM_PACKAGES/share/man:$(manpath)" like said in the terminal message and I pasted it in bashrc and saved. (sudo gedit ~/.bashrc)

Then I source the bashrc

source ~/.bashrc

But still no packages are available. (gulp, yo etc)

Please help me! I can provide more details.

asimkt commented 8 years ago

I can see .npm/ folder with all those packages. and another $npmdir/.npm-packages with nothing.

Attaching my bashrc:

bashrc (copy).txt

sindresorhus commented 8 years ago

This is not a support forum. Try asking on Stack Overflow ;)

asimkt commented 8 years ago

@sindresorhus :) I thought, since you have the link to that script, you could help. (https://github.com/sindresorhus/guides/blob/master/npm-global-without-sudo.md) Anyway I reinstalled every package which uninstalled by that script.

sindresorhus commented 8 years ago

Open an issue on https://github.com/glenpike/npm-g_nosudo Might be something they can do there.