17

I want to include angular JS Using require so I am using below code

var ang = require('angular');

But It displays error

ReferenceError: window is not defined

I Know window object not defined in node console but help me how to avoid this error ?

I hope my question understandable.

1 Answer 1

19

The window object is only defined in the browser, and isn't defined within Node.js (which uses process instead).

The reason you're getting this error is because you're trying to require a module (angular.js) that was intended to be used with the DOM from a browser, and not within the Node.js environment.

If you want to include angular in your HTML code, include it like you would any other JS file using a tag.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.