解决npm install -g 找不到模块的问题

1.sudo npm install -g underscore
npm http GET https://registry.npmjs.org/underscore
npm http 304 https://registry.npmjs.org/underscore
[email protected] /usr/local/lib/node_modules/underscore
2.vim .profile
export NODE_PATH=/usr/local/lib/node_modules
3.vim test.js
  var us=require('underscore');
  us.each([1,2,3],function(item){console.log(item);});
4.node test.js
1
2
3

你可能感兴趣的:(Nodejs)