从虚拟文件系统加载节点模块

时间:2016-11-23 16:17:35

标签: node.js filesystems node-modules virtualfilesystem

我试图从虚拟文件系统加载一些节点模块 但我不能让它发挥作用

Option Explicit
Public Const DIR_SDR_PRODUCT_DEFINITIONS_FILEPATH As String = "U:\Research_Dev Docs\DevFolder\SDR Sheet\SDRProductDefinitionsICE.xlsx"

Public Sub TranslateAndPullProductInformation()

    Dim lastRow As Integer, loopCounter As Integer
    Dim sdrICEDefinitions As Workbook
    Dim DefinitionsSheet As Worksheet
    Dim findString As String, productTypeString As String, marketTypeString As String, contractTypeString As String
    Dim searchRange As Range, findValuesRange As Range, replaceValuesRange As Range

    'Checks file exists in specificed path, assigns workbook name, assigns proper worksheet for information definitions
    If Len(Dir(DIR_SDR_PRODUCT_DEFINITIONS_FILEPATH)) = 0 Then GoTo BAIL_OUT

    Set sdrICEDefinitions = Workbooks.Open(DIR_SDR_PRODUCT_DEFINITIONS_FILEPATH)

    Set DefinitionsSheet = sdrICEDefinitions.Sheets(1)

    Set searchRange = DefinitionsSheet.Range("A:A")

    lastRow = MainInputSheet.Cells(MainInputSheet.Rows.Count, "D").End(xlUp).Row

    For loopCounter = 2 To lastRow

        If IsEmpty(MainInputSheet.Cells(loopCounter, 3)) = True Then

            findString = MainInputSheet.Cells(loopCounter, 4).Value

            Set findValuesRange = searchRange.Find(findString)

            Set replaceValuesRange = MainInputSheet.Range(MainInputSheet.Cells(2, 4), MainInputSheet.Cells(lastRow, 4)).Find(findString)

            Do Until replaceValuesRange Is Nothing

                'Product Name
                MainInputSheet.Cells(loopCounter, 1) = findValuesRange.Offset(0, 1).Value

                'Market Type
                MainInputSheet.Cells(loopCounter, 2) = findValuesRange.Offset(0, 2).Value

                'Contract Type
                MainInputSheet.Cells(loopCounter, 3) = findValuesRange.Offset(0, 3).Value

                MainInputSheet.Cells(loopCounter, 4).Value = findString & " FOUND"

                Set replaceValuesRange = MainInputSheet.Range(MainInputSheet.Cells(2, 4), MainInputSheet.Cells(lastRow, 4)).FindNext

                Debug.Print replaceValuesRange.Address

            Loop

        End If

    Next

Exit Sub

BAIL_OUT:

    MsgBox ("ProductDefinitions File not found")

End Sub

我得到的错误是:错误:无法找到模块' async'

现在我尝试使用此模块https://www.npmjs.com/package/app-module-path添加我的虚拟路径,但它只获取物理路径。

有人可以帮我解决这个问题吗?

不要担心安全问题我将使用加密技术。

1 个答案:

答案 0 :(得分:2)

unionfs的作者写道requirenode.js的新版本中不起作用:

// NOTE: This does not work in new Node.js
// Now you can also do:
// require('/usr/mem/dir/hello.js');
// Hello world!
// require('/project/hello.js');
// Hello world!

https://github.com/streamich/unionfs/blob/master/examples/example.js#L41