我正在尝试使用Karma进行测试,我正在遵循Angulars自己的测试指南。目前我正在使用最基本的测试类,但在运行它时遇到了问题。
测试类别:
describe('1st test',()=>{
it('true is true', ()=> expect(true).toBe(true)); });
当我使用npm test运行它时,在命令提示符中出现以下错误:
[1] 24 04 2017 11:27:24.957:WARN [web-server]: 404: /base/node_modules/socket.io-client/dist/socket.io.js
[1] Chrome 57.0.2987 (Windows 10 0.0.0) ERROR
[1] {
[1] "__zone_symbol__error": {
[1] "originalStack": "Error: (SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "zoneAwareStack": "Error: (SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js"
[1] },
[1] "stack": "(SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "name": "Error",
[1] "message": "(SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "originalStack": "Error: (SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "zoneAwareStack": "Error: (SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "__zone_symbol__stack": "(SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "originalErr": {
[1] "__zone_symbol__error": {
[1] "originalStack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "zoneAwareStack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js"
[1] },
[1] "stack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "name": "Error",
[1] "message": "XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "originalStack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "zoneAwareStack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "__zone_symbol__currentTask": {
[1] "type": "microTask",
[1] "state": "notScheduled",
[1] "source": "Promise.then",
[1] "zone": "<root>",
[1] "cancelFn": null,
[1] "runCount": 0
[1] },
[1] "__zone_symbol__stack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "__zone_symbol__message": "XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "__zone_symbol__name": "Error",
[1] "__zone_symbol__originalStack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "__zone_symbol__zoneAwareStack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js"
[1] },
[1] "__zone_symbol__currentTask": {
[1] "type": "microTask",
[1] "state": "notScheduled",
[1] "source": "Promise.then",
[1] "zone": "<root>",
[1] "cancelFn": null,
[1] "runCount": 0
[1] },
[1] "__zone_symbol__name": "Error",
[1] "__zone_symbol__message": "(SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "__zone_symbol__originalStack": "Error: (SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "__zone_symbol__zoneAwareStack": "Error: (SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js"
[1] }
[1]
[1] Chrome 57.0.2987 (Windows 10 0.0.0) ERROR
[1] {
[1] "__zone_symbol__error": {
[1] "originalStack": "Error: (SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "zoneAwareStack": "Error: (SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js"
[1] },
[1] "stack": "(SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "name": "Error",
[1] "message": "(SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "originalStack": "Error: (SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "zoneAwareStack": "Error: (SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "__zone_symbol__stack": "(SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "originalErr": {
[1] "__zone_symbol__error": {
[1] "originalStack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "zoneAwareStack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js"
[1] },
[1] "stack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "name": "Error",
[1] "message": "XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "originalStack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "zoneAwareStack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "__zone_symbol__currentTask": {
[1] "type": "microTask",
[1] "state": "notScheduled",
[1] "source": "Promise.then",
[1] "zone": "<root>",
[1] "cancelFn": null,
[1] "runCount": 0
[1] },
[1] "__zone_symbol__stack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "__zone_symbol__message": "XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "__zone_symbol__name": "Error",
[1] "__zone_symbol__originalStack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js",
[1] "__zone_symbol__zoneAwareStack": "Error: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js"
[1] },
[1] "__zone_symbol__currentTask": {
[1] "type": "microTask",
[1] "state": "notScheduled",
[1] "source": "Promise.then",
[1] "zone": "<root>",
[1] "cancelFn": null,
[1] "runCount": 0
[1] },
[1] "__zone_symbol__name": "Error",
[1] "__zone_symbol__message": "(SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "__zone_symbol__originalStack": "Error: (SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js",
[1] "__zone_symbol__zoneAwareStack": "Error: (SystemJS) XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError: XHR error (404 Not Found) loading src/node_modules/socket.io-client/dist/socket.io.js\n\tError loading src/node_modules/socket.io-client/dist/socket.io.js as \"socket.io-client\" from src/app/global/socket.service.js"
[1] }
我已经检查了它找不到的文件,它存在于错误所述的目录中,所以我不知道该怎么办。
这些是XHR请求的404错误。这并不意味着文件系统中不存在该文件,而是通过访问该特定路径不提供该文件。您的服务器不太可能为整个文件系统提供服务,因此您不应该担心该文件是否存在,而是担心它是否是从您的程序试图访问它的特定URL提供的。
有关示例,请参阅此答案中的代码示例:
这里socket.io.js
文件在超文本标记语言中引用为:
<script src="/socket.io/socket.io.js"></script>
不是文件系统中的绝对路径,也不是包含node_modules
的路径。HTTP 请求中的路径和文件系统中的路径是不同的,404 错误是特定于 HTTP 的。
问题内容: 由于某些原因,我的节点服务器无法提供路由,所以我总是会收到404错误。 我尝试编译不同的节点版本( 当前 版本 为0.6.13,该 版本 也可以在实际运行的服务器上运行 )。 从app.js 尝试调用socket.io.js时,我得到并没有错误。 我从本地主机和端口8000尝试,我使用express框架 这是来自app.js的代码: 问题答案: 请检查您的Express版本。Expre
我指的是一个问题,已经被问了很多次,但其他地方发布的解决方案没有解决我的问题ie Socket.io.js找不到。 错误消息为 获取http://127.0.0.1:3000/socket.io/socket.io.js 404 一些附加信息:在我的app.js中:我引用了服务器套接字 '/javascripts/sockets/client.js'是我的客户端套接字:
我的错误: 获取http://***/socket.io/socket.io.js 404(未找到) 本地主机:1未捕获的引用错误:未定义io Index.Jade
我正在尝试在linux上运行mocha测试 错误:未找到测试文件:“test/”npm ERR!测试失败。详见上文。 这是我的包 使用的命令:npm install--global mocha npm i并运行我正在使用npm test的测试 项目结构:
问题内容: 我试图在我的freebsd服务器上运行一个node.js应用程序,但是我无法让socket.io库使用它。我试过包括: 这给出了404错误,并且如果我直接链接到该文件(即它在我的public_html文件夹中的位置),则会收到未定义的错误。 提前致谢 问题答案: 尝试创建另一个包含这一行的node.js应用程序,然后使用node.js运行它 然后,在浏览器中访问,您将获得友好的“欢迎使
问题内容: 我正在尝试安装一些示例的依赖项:我已经下载了npm ,但是所有应用程序都抛出相同的错误: 堵塞似乎是: 没有这样的文件或目录’c:\ node \ stylus \ package.json 我是否错过了创建的步骤? 我在run: Windows 7 64位 npm 1.1.1 node6.11 express2.5.8 问题答案: 更新2018 这已成为一个很受欢迎的问题,我的回答(