简体   繁体   English

npm | 用户文件夹上的node_modules

[英]npm | node_modules on Users folder

I'm little bit confused after try to solve how to install a module globally using npm. 在尝试解决如何使用npm全局安装模块后,我有点困惑。

I installed Node using a .dmg package from official site. 我使用官方网站的.dmg软件包安装了Node。 This is the final log. 这是最终的日志。

Node was installed at 节点安装在

/usr/local/bin/node

npm was installed at npm安装在

/usr/local/bin/npm

Make sure that /usr/local/bin is in your $PATH. 确保/ usr / local / bin在$ PATH中。

From terminal I normally install modules using: for eg 我通常从终端使用以下命令安装模块:

npm install -g bower or npm install bower

But, I never could use 但是,我永远无法使用

 bower
 -bash: bower: command not found

So I looked for 所以我寻找

npm prefix
/Users/cleliodpaula
npm prefix -g
/Users/cleliodpaula/.node

npm ls
/Users/cleliodpaula
├─┬ appbuilder@2.1.1-61

How I can Install properly the Node, NPM and their modules? 如何正确安装Node,NPM及其模块?

edit: 编辑:

I already installed it. 我已经安装了。 But the installed bower, are not in the 但是已安装的凉亭不在

/usr/local/bin

but, int the: 但是,int:

/Users/cleliodpaula/.node/bin/

Bower is not part of NPM, you need to install it separately: Bower不是NPM的一部分,您需要单独安装:

npm install -g bower

Then you will have the executable in /usr/local/bin/bower and you will be able to use the bower command in Terminal. 然后,您将在/usr/local/bin/bower拥有可执行文件,并且能够在Terminal中使用bower命令。

The difference between npm install -g and npm install is that npm install -g installs the module globally (executable will be placed into /usr/local/bin ). npm install -gnpm install之间的区别是npm install -g全局安装模块(可执行文件将放置在/usr/local/bin )。 If you just use npm install , then NPM will install the package into node_modules directory under the current one. 如果仅使用npm install ,那么NPM会将软件包安装到node_modules目录下的node_modules目录中。 In that case you can execute the command as ./node_modules/bower/bin/bower . 在这种情况下,您可以将命令执行为./node_modules/bower/bin/bower

Edit: As I can see your NPM global path is set to /Users/cleliodpaula/.node/bin/ . 编辑:据我所见,您的NPM全局路径设置为/Users/cleliodpaula/.node/bin/ If you want packages to be installed in /usr/local/bin , then change the configuration of NPM: 如果要将软件包安装在/usr/local/bin ,请更改NPM的配置:

npm config set prefix /usr/local

You can also add /Users/cleliodpaula/.node/bin/ if you prefer packages to be installed in /Users/cleliodpaula/.node/bin/ : 您还可以添加/Users/cleliodpaula/.node/bin/如果你喜欢安装在包/Users/cleliodpaula/.node/bin/

export PATH=/Users/cleliodpaula/.node/bin/:$PATH

SOLVED: 解决了:

Install Command Line Tools + Open Xcode. 安装命令行工具+打开Xcode。 The npm and node wasn't installed properly because that. 由于该原因,npm和节点未正确安装。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM