通过 NPM 安装 less 后,lessc 二进制文件不可用

发布于 2024-12-29 21:15:07 字数 500 浏览 6 评论 0原文

我继续安装并测试了node.js,然后通过NPM安装了LESS CSS,但是当我输入命令

lessc styles.less

lessc styles.less > styles.css

它告诉我-bash:lessc:命令未找到

我在MAC Lion中终端程序

编辑

安装 Node 后,您需要运行此命令

ln -s ~/.npm/less/1.2.1/package/bin/lessc (path to directory you want)

然后您将能够在该目录中的任何 less 文件上运行 less。

它可以工作,但它不会将导入编译到一个 CSS 文件中。它只是将导入保留在文件中。我希望能够将导入的文件中的所有 CSS 组合在一起。

I went ahead and installed and tested node.js and then I installed LESS CSS via NPM but when I type in the command

lessc styles.less

or

lessc styles.less > styles.css

It tells me -bash: lessc: command not found

I'm in MAC Lion Terminal program

EDIT:

After installing Node you need to run this command

ln -s ~/.npm/less/1.2.1/package/bin/lessc (path to directory you want)

Then you will be able to run less on any of the less files in that directory.

It works but it's not compiling the imports into one CSS file. It just leaves the imports in the file as is. I was hoping I could combine all of the CSS inside the files that I'm importing together.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

薄凉少年不暖心 2025-01-05 21:15:07

当您通过 npm 安装 LESS 时,请使用 -g 选项进行全局安装。

npm install -g less

When you install LESS via npm use the -g option to install it globally.

npm install -g less

遗忘曾经 2025-01-05 21:15:07

使用 npm 安装软件包时,您有两种选择:

  1. 全局安装: npm install -g
  2. ~/.npm 下的主目录中本地安装npm install

如果您选择选项 1,您的系统应该能够找到二进制文件 lessc。如果您选择选项 2,您应该将 ~/.npm/less/path_to_bin_directory 添加到您的路径:

export PATH=~/.npm/less/path_to_bin_directory:$PATH

或者更好,如果由于以下原因创建了 ~/node_modules 目录安装:

export PATH=~/node_modules/less/path_to_bin_directory:$PATH

When installing packages with npm you have two options:

  1. Install them globally: npm install -g <package>
  2. Install locally in your home directory under ~/.npm: npm install <package>

If you choose option 1 your system should be able to locate the binary lessc. If you choose option 2 you should add ~/.npm/less/path_to_bin_directory to your path:

export PATH=~/.npm/less/path_to_bin_directory:$PATH

or better, if a ~/node_modules directory has been created as a result of installation:

export PATH=~/node_modules/less/path_to_bin_directory:$PATH
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文