sintaxi / harp

Static Web Server/Generator/Bundler
http://harpjs.com
5k stars 346 forks source link

Error in less.js when running harp compile #595

Closed herkyl closed 6 years ago

herkyl commented 7 years ago

I'm getting this error from less.js when running harp compile. I'm using nvm and tried other node versions, all get the same error. Harp server works fine.

/Users/serge/.nvm/versions/node/v6.2.0/lib/node_modules/harp/node_modules/terraform/lib/stylesheet/processors/less.js:25
      return callback(null, css.css, css.map.toString())
                                            ^

TypeError: Cannot read property 'toString' of undefined
  at /Users/serge/.nvm/versions/node/v6.2.0/lib/node_modules/harp/node_modules/terraform/lib/stylesheet/processors/less.js:25:45
  at /Users/serge/.nvm/versions/node/v6.2.0/lib/node_modules/harp/node_modules/less/lib/less/render.js:35:17
  at /Users/sergeherkul/.nvm/versions/node/v6.2.0/lib/node_modules/harp/node_modules/less/lib/less/parse.js:63:17
  at Object.finish [as _finish] (/Users/serge/.nvm/versions/node/v6.2.0/lib/node_modules/harp/node_modules/less/lib/less/parser/parser.js:183:28)
  at Object.ImportVisitor._onSequencerEmpty (/Users/serge/.nvm/versions/node/v6.2.0/lib/node_modules/harp/node_modules/less/lib/less/visitors/import-visitor.js:35:14)
  at ImportSequencer.tryRun (/Users/se%       
oakland commented 7 years ago

I have the same problem with you, and my OS is windows 7, node-version is 6.9.4. There will be an empty asset folder after compiling, so I have to copy all the js, css, and pictures into the www folder and place them into the correct location. Hope somebody can help.

pvu11 commented 7 years ago

I ran into the same thing while compiling: TypeError: Cannot read property 'toString' of undefined at /usr/local/lib/node_modules/harp/node_modules/terraform/lib/stylesheet/processors/less.js:25:45 at /usr/local/lib/node_modules/harp/node_modules/less/lib/less/render.js:35:17 at /usr/local/lib/node_modules/harp/node_modules/less/lib/less/parse.js:63:17 at Object.finish [as _finish] (/usr/local/lib/node_modules/harp/node_modules/less/lib/less/parser/parser.js:183:28)

node v6.9.4, OS Mac El Capitan

herkyl commented 7 years ago

What I did was convert all of my LESS code to SASS, I know it's a lousy fix but works for now

maiduchuy commented 7 years ago

I'm having the same issue on windows 10, nodejs 6.9.5, npm 5.0.3.

akehsanz commented 7 years ago

why man why?? Still the problem persists in Aug 2017? I'm also facing same issue on Win7 x64, nodejs 6.11.0 npm 3.10.10

benpetersen commented 6 years ago

This is not related to the harp repo, rather a node_module they use called terraform. Downgrading to version 1.2 or 1.3 did not resolve this, instead to get your project to compile, you can do either of these two things

  1. Removed all .less files and converted to .scss
  2. Do some coding your global harp node_modules folder 2.1 Remove .less from node_modules\terraform\lib\helpers\raw.js line 16 "html": ["ejs", "md"] 2.2 Add in two lines on node_modules\terraform\lib\stylesheet\processors\less.js add in the following css= css || ""; css.map = css.map || ""; Note: This will at least cause it not to fail when building if you have less files in your app, but they may not be updated.
marykatefain commented 6 years ago

I had this same issue, but it only applied to empty .less files. As soon as I filled them with styles it worked. I think this is just a bug that doesn't know what to do with an empty .less file. Are people seeing this with files that contain styles?

sintaxi commented 6 years ago

@benpetersen @marykatefain thanks so much for the help. An empty .less files was causing the sourcemap to break. https://github.com/sintaxi/terraform/commit/63a0c7dd41c5afb933944db5cdb23ca710fbfb8d

A release of harp@0.24.1 fixes the issue.