NPM : how to source ./node_modules/.bin folder?

2019-04-04 21:54发布

I have a problem on npm installation

I have created a project say project A

cd ~/projectA
npm install sails

but sails command is not found after installation.

I know that it is successfully install in ~/projectA/node_modules directory. but the executable cannot be sourced. And i know it is installed ~/projectA/node_modules/.bin

How can I source the .bin automatically whenever I enter into this projectA folder?

Did I did something wrong?

7条回答
手持菜刀,她持情操
2楼-- · 2019-04-04 22:34

A bit more robust is:

export PATH=$(npm bin):$PATH

You can either run it, add it to your shell profile, or create an alias like:

alias snpm='export PATH=$(npm bin):$PATH'

If you do go the alias route, be sure to use single quotes so it delays the execution of the variables!

查看更多
登录 后发表回答