mac npm global installation error Solution

Solution

One solution is to give the official position npm of global installed somewhere else, because the default installation location is / usr / local / lib folder where this folder is a file system location, so there may be some literacy problems . The installation root directory module is set in the general folder is not so much the problem, here is the official method:

# 第一步:在你的用户文件下新建一个文件夹,这个.npm-global 名字可以用你自己喜欢的名字替换,推荐直接使用这个名字。
mkdir ~/.npm-global
#第二步:更改node的安装连接
npm config set prefix '~/.npm-global'
#第三步:在用户的profile下增加path,为的是系统能够找到可执行文件的目录
 export PATH=~/.npm-global/bin:$PATH
#第四步:update profile。使其生效
source ~/.profile

After four steps above, can be used npm installed, the effect is as follows:

/Users/zyc/.npm-global/bin/webpack -> /Users/xxx/.npm-global/lib/node_modules/webpack/bin/webpack.js > fsevents@1.1.3 install /Users/xxx/.npm-global/lib/node_modules/webpack/node_modules/fsevents > node install [fsevents] Success: "/Users/xxx/.npm-global/lib/node_modules/webpack/node_modules/fsevents/lib/binding/Release/node-v59-darwin-x64/fse.node" is installed via remote > uglifyjs-webpack-plugin@0.4.6 postinstall /Users/zyc/.npm-global/lib/node_modules/webpack/node_modules/uglifyjs-webpack-plugin > node lib/post_install.js + webpack@3.10.0 added 367 packages in 31.471s 

We can see the above installation command has shown that the newly installed webpack has been installed under the user .npm-globalfolder below the. Use this command to note that it is possible to install before you can not use some of the modules in the default position, the solution is to reinstall the original location of the module or copied to the new file location, or add the original file in the profile path location of the file, in order to not make mistakes, or directly re-install it.



Author: Bei Jing
link: https: //www.jianshu.com/p/31744aa44824
Source: Jane books
are copyrighted by the author. Commercial reprint please contact the author authorized, non-commercial reprint please indicate the source.

Guess you like

Origin www.cnblogs.com/dasianer/p/12551214.html