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

后端 未结 8 1891
慢半拍i
慢半拍i 2021-02-19 14:23

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 fo

8条回答
  •  旧巷少年郎
    2021-02-19 14:44

    You should use the npm bin command to get an absolute path to your current node bin directory.

    For example:

    ➤ lessc
    bash: lessc: command not found
    ➤ npm bin
    /home/brice/[...]/node_modules/.bin
    ➤ export PATH=$(npm bin):$PATH
    ➤ lessc --version
    lessc 1.7.3 (Less Compiler) [JavaScript]
    

    This avoids the problem of relative paths, especially if you're going to be using this in a build system that will invoke the command in subdirectories.

提交回复
热议问题