-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Description
protobuf.js version: 6.8.8
- Assume I'm storing my javascript files in
\\DESKTOP-2PLO61T\distributed\node\my-package\
- Attempt to load
api.proto
from\\DESKTOP-2PLO61T\distributed\node\my-package\node_modules\protobufjs\google\protobuf\api.proto
usingRoot.load()
util.path.resolve()
callsutil.path.normalize()
and the path toapi.proto
changes to/DESKTOP-2PLO61T/distributed/node/my-package/node_modules/protobufjs/google/protobuf/api.proto
- Note the single forward slash at the beginning of the path instead of two back slashes
- Exception thrown because the normalized path is not a valid path to
api.proto
index.js:
var path = require('path');
var Protobuf = require("protobufjs");
var sourceDir = path.join(path.dirname(require.resolve('protobufjs')), 'google', 'protobuf');
var file = path.join(sourceDir, "api.proto");
Protobuf.loadSync(file).toJSON(); // Exception
package.json:
{
"name": "test",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"protobufjs": "^6.8.8"
}
}
Exception from running node \\DESKTOP-2PLO61T\distributed\node\my-package\index.js
:
\\DESKTOP-2PLO61T\distributed\node\my-package\node_modules\protobufjs\src\root.js:94
throw err;
^
Error: ENOENT: no such file or directory, open '/DESKTOP-2PLO61T/distributed/node/my-package/node_modules/protobufjs/google/protobuf/api.proto'
at Object.openSync (fs.js:443:3)
at Object.readFileSync (fs.js:343:35)
at fetch (\\DESKTOP-2PLO61T\distributed\node\my-package\node_modules\protobufjs\src\root.js:160:34)
at Root.load (\\DESKTOP-2PLO61T\distributed\node\my-package\node_modules\protobufjs\src\root.js:194:13)
at Root.loadSync (\\DESKTOP-2PLO61T\distributed\node\my-package\node_modules\protobufjs\src\root.js:235:17)
at Object.loadSync (\\DESKTOP-2PLO61T\distributed\node\my-package\node_modules\protobufjs\src\index-light.js:69:17)
at Object.<anonymous> (\\DESKTOP-2PLO61T\distributed\node\my-package\index.js:6:10)
at Module._compile (internal/modules/cjs/loader.js:778:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
If you think this is a valid issue and there's no workaround, I'll try to find time to make a PR to address it.
Metadata
Metadata
Assignees
Labels
No labels