systemjs / builder

SystemJS build tool
MIT License
465 stars 122 forks source link

nodelibs-http 'no window object present' error in 0.10.5 #154

Closed frankwallis closed 9 years ago

frankwallis commented 9 years ago

Hi - I am getting this error when doing an SFX bundle in 0.10.5, if I downgrade to 0.10.4 then everything works ok again:

[20:14:23] Build error:
[20:14:23] [Error: Error loading "github:systemjs/plugin-css@0.1.10/css-builder" at file:/Users/frank/work/tower/jspm_packages/github/systemjs/plugin-css@0.1.10/css-builder.js
Error evaluating file:/Users/frank/work/tower/jspm_packages/github/systemjs/plugin-css@0.1.10/css-builder.js
Error evaluating file:/Users/frank/work/tower/jspm_packages/npm/clean-css@3.1.9.js
Error evaluating file:/Users/frank/work/tower/jspm_packages/npm/clean-css@3.1.9/index.js
Error evaluating file:/Users/frank/work/tower/jspm_packages/npm/clean-css@3.1.9/lib/clean.js
Error evaluating file:/Users/frank/work/tower/jspm_packages/npm/clean-css@3.1.9/lib/imports/inliner.js
Error evaluating file:/Users/frank/work/tower/jspm_packages/github/jspm/nodelibs-http@1.7.1.js
Error evaluating file:/Users/frank/work/tower/jspm_packages/github/jspm/nodelibs-http@1.7.1/index.js
file:/Users/frank/work/tower/jspm_packages/github/jspm/nodelibs-http@1.7.1/index.js:54
      throw new Error('no window object present');
            ^
no window object present]
guybedford commented 9 years ago

@frankwallis I'd be interested to know how you're driving the build here? Is it via jspm bundle-sfx on the command-line? If so can you confirm which version of SystemJS you are seeing in jspm_packages?

Basically this issue will only happen if for some reason SystemJS is not detecting the node environment, and having System._nodeRequire set.

frankwallis commented 9 years ago

I'm calling systemjs-builder from a gulp task, see here

guybedford commented 9 years ago

I would suggest adding a console.log to check if builder.loader._nodeRequire is defined just before https://github.com/frankwallis/tower/blob/master/tasks/bundle/bundle-builder.js#L32.

guybedford commented 9 years ago

It would be good to know how it's not being set, so help tracking it down appreciated.

frankwallis commented 9 years ago

It was caused by calling reset() multiple times - it gets called in the Builder constructor and I was calling it myself. When I took out the second call it started working ok. I have submitted a patch for the actual problem.

mcMickJuice commented 8 years ago

@guybedford why is this occurring? I'm seeing this error when using http library and wepback to bundle up my node code. Is there a check in the http library to use XMLHttpRequest if it thinks its in a browser environment?

I know this isn't related to system.js but any insight into this would be awesome!