Lesscss command line compiler Lessc - macos

Hi Im trying to get the LessCss command line compiler installed on a Mac.
I've tried
brew install less
Error: No available formula for less
brew install lessc
Error: No available formula for lessc
sudo npm install -g less
..Installs happily..
sudo npm install -g lessc
npm http GET https://registry.npmjs.org/lessc
npm http 404 https://registry.npmjs.org/lessc
npm ERR! 404 'lessc' is not in the npm registry.
npm install less --global
..Installs happily..
npm install lessc --global
npm http GET https://registry.npmjs.org/lessc
npm http 404 https://registry.npmjs.org/lessc
npm ERR! 404 'lessc' is not in the npm registry.
and all I get is
less js/less/style.less > style-theme.css
-bash: less: command not found
lessc js/less/style.less > style-theme.css
-bash: lessc: command not found
Does anyone have any experience with this?
I found something said my path variable might be messed up. This:
/bin/echo $PATH
gets me:
/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/git/bin

the npm package name for lessc is less
try writing
sudo npm install -g less

I will try to provide a complete answer.
All commands must be executed in the Terminal application.
If you don't have it: Install Command Line Tools for Xcode
xcode-select --install
If you don't have it: Install HomeBrew
ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"
If you don't have it: Install Node.js
brew install node
Install LessCSS
sudo npm install -g less
Now you can execute lessc commands.

i`m using macOS Siera and work for me, you can try:
install npm using brew:
brew install node
check node and npm version using:
node -v
npm -v
3.change user to SU using:
sudo su
install less:
npm install -g less
Good Luck.....

Related

Unable to install React Native cli on Mac using npm

Unable to install React Native cli on Mac using npm!
I have tried uninstalling both node and npm and trying the command npm install -g react-native-cli.
Also tried this,
"If you get an error like Cannot find module 'npmlog', try installing npm directly: curl -0 -L https://npmjs.org/install.sh | sudo sh"
Use sudo npm install -g react-native-cli
Also, you can use Yarn!

how to update npm on macOS

For reasons unknown to me, I haven't been able to update to the latest version of npm on macOS (it works fine on Windows). It displays no error, only 'updated 1 package'.
Using Node.js 8.11.1
node -v
v8.11.1
What version of npm do I have?
$ npm -v
5.6.0
I tried this...
$ npm i -g npm
+ npm#5.8.0
updated 1 package in 7.37s
And it fails to update.
$ npm -v
5.6.0
Where is npm?
$ which npm
/usr/local/bin/npm
So I try brew...
brew install npm
And it fails...
$ npm -v
5.6.0
*And then I tried this... *
npm install npm#latest -g
+ npm#5.8.0
updated 1 package in 7.618s
And it fails...
npm -v
5.6.0
With sudo:
sudo npm i -g npm
+ npm#5.8.0
updated 1 package in 7.794s
And it fails...
npm -v
5.6.0
This also fails...
sudo npm install npm#latest -g
I followed the directions found on this Q&A, completely removing npm and node from my system and reinstalling them from scratch, and it also fails to update.
Screenshot, per request:
Close the terminal, and then re-open the terminal and running:
$ npm -v
5.6.0
sudo twice:
$ sudo npm i -g npm
+ npm#5.8.0
updated 1 package in 7.478s
$ sudo npm i -g npm
+ npm#5.8.0
updated 1 package in 7.434s
Also fails:
$ npm -v
5.6.0
What did I miss? What's going on here?
This works on my mac.
Based on docs https://docs.npmjs.com/troubleshooting/try-the-latest-stable-version-of-npm :
npm install -g npm#latest
There is a note stated on the docs that depends on your installation method, you might addd some sudo.
Upgrading on *nix (OSX, Linux, etc.)
(You may need to prefix these commands with sudo, especially on Linux,
or OS X if you installed Node using its default installer.)
npm install -g npm#latest
works fine!!
and you can also replace the latest for specific versions
like
npm install -g npm#5.6.0
I hope it will help!!!
Perhaps you have already solved this, but here is what I found when I had exactly this issue. I had 2 versions of npm installed.
I verified this as follows:
grep \"version\" ~/.npm-packages/lib/node_modules/npm/package.json
"version": "6.2.0"
grep \"version\" /usr/local/lib/node_modules/npm/package.json
"version": "5.6.0",
I worked around the issue by updating the path in my bash profile, but would like to know why (how) I ended up with 2 versions. Here is the update:
tail -2 ~/.bash_profile
NPM_PACKAGES="${HOME}/.npm-packages"
PATH="$NPM_PACKAGES/bin:$PATH"
In my case, none of the previous answers worked. For me, a working solution was a simple, five-step process.
Make sure (the old version of) npm is installed.
npm -v
If npm is not installed, then install it on the Mac with Node.js.
Globally installed the desired version of npm.
npm install -g npm#latest
This command uses the old version of npm (installed by Node), to globally install the latest version of npm at ~/.npm-global/. Once installed, close and open a new terminal shell.
Remove the old version of npm installed by Node
rm -r /usr/local/lib/node_modules/npm/
Sometimes this doesn't work, so I had to go into finder to delete the /npm/ folder.
Make sure to set the correct path variable.
echo $PATH
If ~/.npm-global/bin does not show up between the colons, then update the path variable. Open up ~/.zshrc in a text editor and add the following line. If you don't use zsh, open the profile for your corresponding shell (i.e. ~/.bash_profile)
export PATH=$PATH:$HOME/.npm-global/bin
Save your changes and close the text editor.
Close and reopen the terminal shell and run npm -v to check that npm is correctly on the latest version.
The reason for updating the path variable is because the npm cli suggests you update npm with npm install -g npm which will install npm at a different location than where Node installs npm originally.
In my case, only the following has helped:
sudo rm -rf /usr/local/lib/node_modules
sudo rm -rf ~/.npm
brew uninstall --ignore-dependencies node
brew install node
EDIT NOV 21: These days, I bypass brew entirely and use "n":
https://www.npmjs.com/package/n
And so I can change between versions too.
I faced the same problem.
You might have already installed the npm version, and now it is time to point the new npm version install. You can do that by following below steps.
sudo nano /usr/local/lib/node_modules/npm/package.json
change "version" : "5.6.0" to "verison": "5.8.0"
In my case, I'm using nvm to manage different versions of node. In order to upgrade npm version, I have to
1 - Install the latest version of npm by navigating to your current
version of node
cd ~/.nvm/versions/node/v10.9.0
npm install npm
or you can probably use
nvm install-latest-npm
2 - Edit $PATH to point to your current version of node
NPM_PACKAGES="${HOME}/.nvm/versions/node/v10.9.0"
PATH="$NPM_PACKAGES/bin:$PATH"
On my macOS the homebrew-installed npm did not want to upgrade due to pre-existing link file. I ran the install with --force flag and now things are okay.
$ npm --version
6.14.16
$ npm install -g npm#8
npm ERR! EEXIST: file already exists, symlink ...
$ npm install -g --force npm#8
npm WARN using --force I sure hope you know what you are doing.
+ npm#8.19.2
$ npm --version
8.19.2
Note also that in my case, no 'sudo' was required, thanks to homebrew. To check if your npm is installed with homebrew, use brew list.
$ brew list | grep node
node#12

Error:Unable to install composer-cli

When I run npm install -g composer-cli I get this error:
"Need to have composer-cli installed at v0.15 or greater".
How can I resolve that?
Try running the command with --unsafe-perms , like this:
sudo npm install --unsafe-perm -g composer-cli
Reference: https://github.com/nodejs/node-gyp/issues/454
On Ubuntu (the supported Linux development environment) we do not recommend using sudo to install Composer.
The usual reason people would resort to sudo is a permission problem, but it is better to resolve the permission problem rather than use sudo. Often the problem is the npm prefix which can get set to /usr/local to which the user doesn't have write access. Issuing an npm config set prefix /home/<myuser>/ will solve the problem.
You may have an old version of Composer or one of the components installed. Try using npm ls -g --depth=0 to see if you have some composer code already installed, and if so remove it with npm uninstall -g composer-<component> where might be cli, or playground etc. The retry the install-g command.
Try this....this is the command to install 0.20 version.
npm install -g composer-cli#0.20
I changed my node version from
11
to
8.8.15
and did npm install -g composer-cli.It worked for me .
You need to use a 8.* node version,
My solution was:
nvm install 8.9.0
nvm use 8.9.0
npm install -g composer-cli

'Error: not found: git' code: 'ENOGIT' while installing bower

I'm using windows 10 with git and node installed. Running :
npm install -g bower
resulsts in
npm WARN addRemoteGit Error: not found: git
npm WARN addRemoteGit at F (C:\Program Files\nodejs\node_modules\npm\node_modules\which\which.js:78:19)
npm WARN addRemoteGit sheerun/fs-write-stream-atomic#v1.0.4-fix resetting remote C:\Users\Muhammet Akkus\AppData\Roaming\npm-cache\_git-remotes\git-github-com-sheerun-fs-write-stream-atomic-git-v1-0-4-fix-7baaaaefc7e8a6f2fd1f4fdbc8e4b6e7 because of error: { [Error: not found: git] code: 'ENOGIT' }
npm ERR! git clone --template=C:\Users\Muhammet Akkus\AppData\Roaming\npm-cache\_git-remotes\_templates --mirror git://github.com/sheerun/fs-write-stream-atomic.git C:\Users\Muhammet Akkus\AppData\Roaming\npm-cache\_git-remotes\git-github-com-sheerun-fs-write-stream-atomic-git-v1-0-4-fix-7baaaaefc7e8a6f2fd1f4fdbc8e4b6e7: undefined
....
You should try to run this command as root. On Windows, start your CommandLine as administrator and under Mac or Linux use
sudo npm install -g bower
Installing git and running npm install from git-bash worked for me. Make sure you are in the correct directory.
Refer more here for solution
git is not installed or not in the PATH
i use windows and i have same problem when i want to install react-native-router-flux , for me that is solved when i use git bash to install it instead of command line, i hopefully this is help you .

npm already installed but then says "command not found"

I keep having this problem so I uninstalled homebrew and tried to uninstall npm, but it did not work. I installed homebrew again and then typed "brew install npm." It returned "Warning: node-0.12.7 already installed." I then tried to use npm with the following command: "npm install -g mup" and it returned "-bash: npm: command not found."
I have trouble uninstalling npm because on the site it uses npm to uninstall npm... Otherwise, it denies me permission. How can I get around this so that I can install mup with "npm install -g mup"? What's weird is that it was working earlier but now it is failing me. Thank you.
Try this
cd ~
sudo rm -rf .npm
brew update
brew uninstall npm
brew install npm

Resources