Home Ask Login Register

Developers Planet

Your answer is one click away!

Shane February 2016

using local less with npm

Are there any established patterns for running less via npm scripts?

for instance, in my package.json file I have:

{
  "name": "lesstest",
  "description": "less test",
  "main": "dist/index.js",
  "scripts": {
    "build:css": "./node_modules/less/bin/lessc src/less/app.less dist/style.css"
  },
  "devDependencies": {
    "less": "^2.6.0",
  }
}

running:

./node_modules/less/bin/lessc src/less/app.less dist/style.css

from terminal works just fine, but when I run

npm run build:css

I get " '.' is not recognized as an internal or external command, operable program or batch file. " Does this mean that commands in npm scripts cannot include paths? If so, are there any techniques out there to execute a similar intention without using gulp?

Answers


JRJurman February 2016

You can just use "lessc src/less/app.less dist/style.css"

By default, package.json looks in your node_modules folder, and if it can't find it, looks elsewhere, so you can safely use a downloaded dependency as if you had globally installed it.

Post Status

Asked in February 2016
Viewed 3,624 times
Voted 6
Answered 1 times

Search




Leave an answer


Quote of the day: live life