If you’re using npm for development in Liferay DXP, you should set up your npm environment to avoid potential permissions issues. Follow these steps to configure your npm environment:
-
Create an
.npmrc
file in your user’s home directory. This helps bypass npm permission-related issues. -
In the
.npmrc
file, specify aprefix
property based on your user’s home directory, like the one shown below. This value specifies where to install global npm packages:prefix=/Users/[username]/.npm-packages
-
Set the
NPM_PACKAGES
system environment variable to theprefix
value you just specified:NPM_PACKAGES=/Users/[username]/.npm-packages (same as prefix value)
-
Since npm installs Yeoman and gulp executables to
${NPM_PACKAGES}/bin
on UNIX and to%NPM_PACKAGES%
on Windows, make sure to add the appropriate directory to your system path. For example, on UNIX you’d set this:PATH=${PATH}:${NPM_PACKAGES}/bin