使用Grunt的Node JS项目,生成的JS文件有ReferenceError:窗口未定义
Node JS Project with Grunt, produced js file has ReferenceError: window is not defined
错误是这样的混乱,除了这是一个自动生成的js文件,所以我不知道我将如何去修复它。
"E:'Webstorm' Webstorm 2016.1.3'bin'runner .exe" "C:'Program Files'nodejs'node.exe" js' mediation .js .e: ' Meditection ' ' js ' meditection.js Meditection门户:73865})(窗口);^
ReferenceError: window is not defined
at Object.__dirname.8 (e:'Meditection'Meditection Portal'js'meditection.js:73865:4)
at s (e:'Meditection'Meditection Portal'js'meditection.js:1:316)
at e:'Meditection'Meditection Portal'js'meditection.js:1:367
at Object.__dirname.9../angular (e:'Meditection'Meditection Portal'js'meditection.js:73869:1)
at s (e:'Meditection'Meditection Portal'js'meditection.js:1:316)
at e:'Meditection'Meditection Portal'js'meditection.js:1:367
at Object.__dirname.22.angular (e:'Meditection'Meditection Portal'js'meditection.js:76783:1)
at s (e:'Meditection'Meditection Portal'js'meditection.js:1:316)
at e (e:'Meditection'Meditection Portal'js'meditection.js:1:487)
at Object.<anonymous> (e:'Meditection'Meditection Portal'js'meditection.js:1:505)
我的html文件是
<!DOCTYPE html>
<html layout-fill>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="./js/meditection.js"></script>
<link href="./css/meditection.css" rel="stylesheet">
<title>Meditection</title>
</head>
<body ng-app="med.landing" ui-view layout-fill></body>
</html>
这似乎是进入js文件并执行它因此错误,但当我试图访问它所在的本地主机,我得到
在此服务器上找不到请求的URL。如果您手动输入URL,请检查拼写并重试。
所以我的问题是我做错了什么?老实说,这是工作了一段时间,我重新基于我的代码,所以它可能有一些愚蠢的配置问题。
感谢您的帮助<3
您使用的文件不是为node.js环境设计的。
Node没有一个自动的窗口对象,Node应用程序也没有一个附加的文档。
我在windows上遇到了同样的问题,但如果你使用Linux (Ubuntu)或mac,它工作得很好。
Grunt和Grunt插件应该在项目的package.json中定义为devDependencies。这将允许你用一个命令安装项目的所有依赖项:npm install。
相关文章:
- ReferenceError: cordova is not defined @ng-cordova.min.js:7
- Node.js错误“;ReferenceError:全局未定义“;在从0.10.2更新到0.12.2之后
- 尝试将js函数更改为coffeescript时发生Uncaught ReferenceError
- Meteor JS错误”;ReferenceError:X未定义”;
- 测试Ember.JS应用程序失败,返回ReferenceError:未定义Ember
- angular.js:13424 ReferenceError:在控制器中使用工厂方法时未定义索引
- Meteor JS Uncaught ReferenceError:未定义会话
- angular.min.js:63 ReferenceError
- 在Node.js中,从同一文件中的另一个函数引用一个函数会导致'ReferenceError:-函数-未定义
- ReferenceError:Node.js中未定义Intl
- 余烬.js ReferenceError:Firefox 中未定义事件
- Spine.js mobile (phonegap) ReferenceError Jqueryify
- 将 JQuery 与 Node 一起使用.js“ReferenceError: $ 未定义”
- "ReferenceError未知插件“;当我尝试使用babel-cli转换目录中的js文件时
- ReferenceError:BASE_URL未定义,Angular JS依赖项
- 在node.js中开始获取错误未定义Uncaught ReferenceError:模块,未定义Uncaught Ref
- 将socket.io/socket.io.js加载到html头中返回"ReferenceError:io未定义
- 未捕获的ReferenceError:Haxe-js项目中未定义$hxClasses
- ReferenceError:事件未定义firefox d3.js
- Angular2 systemjs.config.js ' "ReferenceError: Syst