You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I compiled node.js from source code with vcbuild.bat on windows os. no problem. then i tried to compile with visual studio 2022. no problem. I tried to run the release version of Embedtest from the Visual Studio 2022 compilation, following the comments instructions in the embedtest.cc file.
// Format of the arguments of this binary:
// Building snapshot:
// embedtest js_code_to_eval arg1 arg2...
// --embedder-snapshot-blob blob-path
// --embedder-snapshot-create
// [--embedder-snapshot-as-file]
// [--without-code-cache]
// Running snapshot:
// embedtest --embedder-snapshot-blob blob-path
// [--embedder-snapshot-as-file]
// arg1 arg2...
// Snapshot number:
// embedtest arg1 arg2...
always fails with error: Cannot find module
output:
(node:14624) Warning: It's not yet fully verified whether built-in module "vm" works in user snapshot builder scripts.
It may still work in some cases, but in other cases certain run-time states may be out-of-sync after snapshot deserialization.
To request support for the module, use the Node.js issue tracker: https://github.com/nodejs/node/issues
(Use embedtest --trace-warnings ... to show where the warning was created)
E:\node
[
'E:\node\out\Release\embedtest.exe',
'__node_anonymous_main',
"const path = require('node:path');console.log(process.cwd());globalThis.path = process.cwd();globalThis.file = path.resolve();const name = 'I am geezy';console.log(process.argv);globalThis.firstArg = process.argv[2];globalThis.secondArg = process.argv[3];",
'name',
'home'
]
Details
I compiled node.js from source code with vcbuild.bat on windows os. no problem. then i tried to compile with visual studio 2022. no problem. I tried to run the release version of Embedtest from the Visual Studio 2022 compilation, following the comments instructions in the embedtest.cc file.
// Format of the arguments of this binary:
// Building snapshot:
// embedtest js_code_to_eval arg1 arg2...
// --embedder-snapshot-blob blob-path
// --embedder-snapshot-create
// [--embedder-snapshot-as-file]
// [--without-code-cache]
// Running snapshot:
// embedtest --embedder-snapshot-blob blob-path
// [--embedder-snapshot-as-file]
// arg1 arg2...
// Snapshot number:
// embedtest arg1 arg2...
always fails with error: Cannot find module
Node.js version
node v.20.12.2
Example code
int main(int argc, char** argv) {
TCHAR szExecutablePath[MAX_PATH];
TCHAR buffer[BUFSIZE] = TEXT("");
TCHAR** lppPart = {NULL};
::GetModuleFileName(NULL, szExecutablePath, MAX_PATH);
::GetFullPathName(szExecutablePath, BUFSIZE, buffer, lppPart);
std::vector<char*> vtarg;
ULONG wchars_num = ::WideCharToMultiByte(CP_UTF8, 0, buffer, -1, NULL, 0, NULL, NULL);
std::vector vtChar(wchars_num);
WideCharToMultiByte(CP_UTF8, 0, buffer, -1, &vtChar[0], wchars_num, 0, NULL);
std::ifstream isf("E:\node\out\Debug\snapshot.js", std::ios_base::in | std::ios_base::binary);
isf.seekg(0, std::ifstream::end);
int len = isf.tellg();
isf.seekg(0, std::ifstream::beg);
char* data = new char[len + 1]; // Add space for the nul terminator ...
isf.read(data, len);
data[len] = '\0';
std::string snapshot = data;
snapshot.erase(std::remove_if(snapshot.begin(), snapshot.end(), [&](char ch){ return std::iscntrl(static_cast(ch));}), snapshot.end());
vtarg.push_back(strdup(std::string(&vtChar[0]).c_str()));
vtarg.push_back(strdup(snapshot.c_str()));
vtarg.push_back(strdup("name"));
vtarg.push_back(strdup("home"));
vtarg.push_back(strdup("--embedder-snapshot-create"));
vtarg.push_back(strdup("--embedder-snapshot-as-file"));
vtarg.push_back(strdup("--embedder-snapshot-blob"));
vtarg.push_back(strdup("./snapshot.blob"));
vtarg.push_back(nullptr);
argv = uv_setup_args(vtarg.size() - 1, vtarg.data());
std::vectorstd::string args(argv, argv + vtarg.size() - 1);
/argv = uv_setup_args(argc, argv);
std::vectorstd::string args(argv, argv + argc);/
std::unique_ptrnode::InitializationResult result =
node::InitializeOncePerProcess(
args,
{node::ProcessInitializationFlags::kNoInitializeV8,
node::ProcessInitializationFlags::kNoInitializeNodeV8Platform});
for (const std::string& error : result->errors())
fprintf(stderr, "%s: %s\n", args[0].c_str(), error.c_str());
if (result->early_return() != 0) {
return result->exit_code();
}
std::unique_ptr platform =
MultiIsolatePlatform::Create(4);
V8::InitializePlatform(platform.get());
V8::Initialize();
output:
(node:14624) Warning: It's not yet fully verified whether built-in module "vm" works in user snapshot builder scripts.
It may still work in some cases, but in other cases certain run-time states may be out-of-sync after snapshot deserialization.
To request support for the module, use the Node.js issue tracker: https://github.com/nodejs/node/issues
(Use
embedtest --trace-warnings ...
to show where the warning was created)E:\node
[
'E:\node\out\Release\embedtest.exe',
'__node_anonymous_main',
"const path = require('node:path');console.log(process.cwd());globalThis.path = process.cwd();globalThis.file = path.resolve();const name = 'I am geezy';console.log(process.argv);globalThis.firstArg = process.argv[2];globalThis.secondArg = process.argv[3];",
'name',
'home'
]
running snapshot:
TCHAR szExecutablePath[MAX_PATH];
TCHAR buffer[BUFSIZE] = TEXT("");
TCHAR** lppPart = {NULL};
::GetModuleFileName(NULL, szExecutablePath, MAX_PATH);
::GetFullPathName(szExecutablePath, BUFSIZE, buffer, lppPart);
std::vector<char*> vtarg;
ULONG wchars_num = ::WideCharToMultiByte(CP_UTF8, 0, buffer, -1, NULL, 0, NULL, NULL);
std::vector vtChar(wchars_num);
WideCharToMultiByte(CP_UTF8, 0, buffer, -1, &vtChar[0], wchars_num, 0, NULL);
std::ifstream isf("E:\node\out\Debug\snapshot.js", std::ios_base::in | std::ios_base::binary);
isf.seekg(0, std::ifstream::end);
int len = isf.tellg();
isf.seekg(0, std::ifstream::beg);
char* data = new char[len + 1]; // Add space for the nul terminator ...
isf.read(data, len);
data[len] = '\0';
std::string snapshot = data;
snapshot.erase(std::remove_if(snapshot.begin(), snapshot.end(), [&](char ch){ return std::iscntrl(static_cast(ch));}), snapshot.end());
vtarg.push_back(strdup(std::string(&vtChar[0]).c_str()));
vtarg.push_back(strdup("require('./index.js')"));
/vtarg.push_back(strdup("name"));
vtarg.push_back(strdup("home"));
vtarg.push_back(strdup("--embedder-snapshot-create"));
vtarg.push_back(strdup("--embedder-snapshot-as-file"));/
vtarg.push_back(strdup("--embedder-snapshot-blob"));
vtarg.push_back(strdup("./snapshot.blob"));
vtarg.push_back(nullptr);
argv = uv_setup_args(vtarg.size() - 1, vtarg.data());
std::vectorstd::string args(argv, argv + vtarg.size() - 1);
/argv = uv_setup_args(argc, argv);
std::vectorstd::string args(argv, argv + argc);/
std::unique_ptrnode::InitializationResult result =
node::InitializeOncePerProcess(
args,
{node::ProcessInitializationFlags::kNoInitializeV8,
node::ProcessInitializationFlags::kNoInitializeNodeV8Platform});
for (const std::string& error : result->errors())
fprintf(stderr, "%s: %s\n", args[0].c_str(), error.c_str());
if (result->early_return() != 0) {
return result->exit_code();
}
std::unique_ptr platform =
MultiIsolatePlatform::Create(4);
V8::InitializePlatform(platform.get());
V8::Initialize();
output:
node:internal/modules/cjs/loader:1146
throw err;
^
Error: Cannot find module 'E:\node\require('.\index.js')'
at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
at Module._load (node:internal/modules/cjs/loader:984:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:135:12)
at node:internal/main/run_main_module:28:49 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
Node.js v20.12.2
Operating system
Windows 11
Scope
runtime
Module and version
Not applicable.
The text was updated successfully, but these errors were encountered: