How to solve 'window is not defined' Error in Node JS on Terminal

后端 未结 1 2053
情深已故
情深已故 2021-02-07 08:09

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

var ang = require(\'angular\');

But It displays error

Refe         


        
相关标签:
1条回答
  • 2021-02-07 08:26

    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.

    0 讨论(0)
提交回复
热议问题