IISNode缓存了旧的文件名,但我似乎无法更新它。

问题描述 投票:0回答:1

你好,先谢谢你!这可能是一个相当简单的方案,但是,我是Nodejs的新手,我有一个主脚本,我使用IISNode从javascript中调用。一切都很好,直到我决定重命名一个依赖文件。

涉及的文件。

  • embed.js <-主脚本
  • dev2.js <-需要自定义脚本,由 embed.js它读取这个json文件
  • fred.json 改名为 chartio.json

embed.js 与问题相关的代码。

var http = require('http');
var jwt = require('jwt-simple');
var dashinfo = require('./dev2');

var ORGANIZATION_SECRET = dashinfo.getkey();
var ORG_ID = dashinfo.getorgid();

dev2.js 与问题相关的代码:

var mariadb = require('mariadb');
var connectioninfo = require('./chartio.json');

module.exports = {
  getkey: function () {
    return connectioninfo.connection.apikey;
  },
  getorgid: function () {
    return connectioninfo.connection.orgid;
  },

最后,我有我的 charti0.json 我向你保证,在我重命名之前,一切都正常。fred.jsonchartio.json.

我在网上看了看有没有办法清除缓存,但是我找不到任何好像有用的方法,虽然我是新手。我也看了日志。我试着在IE和Chrome中运行这个

这是我从错误中看到的记录。

Application has thrown an uncaught exception and is terminated:


Error: Cannot find module './fred.json'
Require stack:
- C:\xxx\xxx\GPS411\node\dev2.js
- C:\xxx\xxx\GPS411\node\embed.js
- C:\Program Files (x86)\iisnode\interceptor.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:794:15)
    at Function.Module._load (internal/modules/cjs/loader.js:687:27)
    at Module.require (internal/modules/cjs/loader.js:849:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (C:\Omnitracs\sylectus-trunk\GPS411\node\dev2.js:3:22)
    at Module._compile (internal/modules/cjs/loader.js:956:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Module.require (internal/modules/cjs/loader.js:849:19)
javascript node.js json caching iisnode
1个回答
0
投票

伙计们,我能够通过做一个老式的工作站重启来让这个工作。我再次更改了文件名,以测试是否问题又回来了,现在似乎可以识别文件的变化。我想我只是卡在了缓存区,但现在我自由了。谢谢你的考虑。

© www.soinside.com 2019 - 2024. All rights reserved.