NPM:如何获取 ./node_modules/.bin 文件夹? [英] NPM : how to source ./node_modules/.bin folder?
问题描述
我在安装 npm 时遇到问题
I have a problem on npm installation
我创建了一个项目,比如项目 A
I have created a project say project A
cd ~/projectA
npm install sails
但是安装后没有找到sails命令.
but sails command is not found after installation.
我知道它已成功安装在 ~/projectA/node_modules
目录中.但无法获取可执行文件.我知道它已安装 ~/projectA/node_modules/.bin
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
每当我进入这个projectA文件夹时,如何自动获取.bin?
How can I source the .bin automatically whenever I enter into this projectA folder?
我做错了什么吗?
推荐答案
我可以给你一个不雅的解决方案,它对我有用.我刚刚在我的 .bashrc 文件中导出了我的路径.
I can give you an inelegant solution, which is working for me. I just exported my path in my .bashrc file.
export PATH="$PATH:./node_modules/.bin"
已经有一段时间了,但我已经改变了使用 npm 脚本的策略.在上面的例子中,设置 package.json 如下:
It's been a while, but I have changed my strategy to use npm scripts instead. In the above case, setup package.json as follows:
"scripts": {
"sails": "sails"
}
然后你可以运行
npm run sails
或带参数
npm run sails -- <args>
这篇关于NPM:如何获取 ./node_modules/.bin 文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!