I try to execute v8 runtime environment from within c++ application to achive js support for my application. I successfully compile v8pp and now try to use the lib in my own console application. Currently I get a lot of unresolved symbol messages and do not get it what is the difference from working unit tests project within v8pp solution. Can someone point me to the right direction of what I am doing wrong here?
Build started...
1>------ Build started: Project: v8pp, Configuration: Debug Win32 ------
1>class.cpp
1>context.cpp
1>convert.cpp
1>json.cpp
1>throw_ex.cpp
1>version.cpp
1>Generating Code...
1>v8pp.vcxproj -> C:\git\v\v8pp\bin\Debug\v8pp.lib
2>------ Build started: Project: ConsoleApplication1, Configuration: Debug Win32 ------
2>ConsoleApplication1.obj : error LNK2019: unresolved external symbol "void __cdecl v8::api_internal::ToLocalEmpty(void)" (?ToLocalEmpty#api_internal#v8##YAXXZ) referenced in function "public: class v8::Local<class v8::Function> __thiscall v8::MaybeLocal<class v8::Function>::ToLocalChecked(void)" (?ToLocalChecked#?$MaybeLocal#VFunction#v8###v8##QAE?AV?$Local#VFunction#v8###2#XZ)
...
From what I can see I use same methods already used in unit tests.
Related
I'm trying to create react typescript app with grpc,
my protoc version is: libprotoc 3.20.1
I'm running this command to compile a proto file:
protoc -I=. src/todo.proto --js_out=import_style=commonjs,binary:. --grpc-web_out=import_style=commonjs,mode=grpcwebtext:.
and getting this error:
protoc-gen-grpc-web: program not found or is not executable
Please specify a program using absolute path or make sure the program is available in your PATH system variable
--grpc-web_out: protoc-gen-grpc-web: Plugin failed with status code 1.
I have created a node.js application. I need to compile or do a check whether syntax error occurs before running the node.js service.I need to integrate this in jenkins. Kindly guide me to validate the node.js application
Look into TypeScript. It is a language which allows you to get autocomplete with types and fails compilation if you have some syntax errors. It is a superset of JavaScript and transpiles to JavaScript.
Node.js provides CLI option --check or -c for checking a given file for syntax errors without running it. When working with Linux or MacOS a command like the following one helps with checking all obvious javascript files in a folder for containing basically working code:
find -name "*.js" | xargs node -c
using eslint package https://www.npmjs.com/package/eslint
It's a very common library to check the syntax of any JS/TS framework
You can use 'node-syntax-error' module.
it helps you to detect and report syntax errors in source code strings.
When you type node src.js you get a friendly error report about exactly where the syntax error is. This module lets you check for syntax errors and report them in a similarly friendly format that wrapping a try/catch around Function() or vm.runInNewContext() doesn't get you.
For example:
var fs = require('fs');
var check = require('syntax-error');
var file = __dirname + '/src.js';
var src = fs.readFileSync(file);
var err = check(src, file);
if (err) {
console.error('ERROR DETECTED' + Array(62).join('!'));
console.error(err);
console.error(Array(76).join('-'));
}
Using
node --check
Only finds very grave errors and can be tricky to execute.
I would suggest to use a linter like 'eslint'. Because:
It integrates easily with (npm lint or yarn lint)
It catches almost all possible errors (way more than node -check)
I just compiled ChakraCore and run Hello World Sample.
when I built ChakraCore there was no error found.
But when I run HelloWorld sampl System.Runtime.InetropServices.SEHException occured at ChakraHost.Hosting.Native.JsCreateContext(JavaScriptRuntime runtime, JavaScriptContext& newContext).
It said external component has thrown an exception.
So I enabled native code debugging and found assertion failure in ChakraCore and Assert message is like below.
AssertMsg(false, "Failed to initialize COM interfaces, verify correct version of globalization dll is used.");
Then I searched for system.globalization.dll file and found the file in multiple folders.
I copied it into C:\windows\SysWOW64 and ran regsvr32 system.globalization.dll.
I got below message from the run.
The module "system.globalization.dll" was loaded but the entry-point DllRegisterServer was not found.
Make sure that "system.globalization.dll"is a valid DLL or OCS file and theny try again.
I don't know what to do now. I have spend hours to solve this problem.
Can anyone help me figure this out please?
Thanks,
Here is what I did to get it working.
Build ChakraCore from Visual Studio 2015. I used debug and x64
Copy ChakraCore/Build/VcBuild/bin/x64_debug.ChakraCore.dll to Chakra-Samples\ChakraCore Samples\Hello World\C#\HelloWorld\bin
Go to HelloWorld solution properties and set Platform target to x64
Add breakpoint in Main method of HelloWorld press F5.
In my case the failing line was always:
// Create a runtime.
Native.JsCreateRuntime(JavaScriptRuntimeAttributes.None, null, out runtime);
After taking the actions mentioned above I get the HelloWorld sample to run.
Hope this helps.
I am new to ember.js and javascript frontend MVCs.
I am running into:
Cannot call 'compile' without the template compiler loaded
https://github.com/emberjs/ember.js/issues/10265
So I added:
app.import('bower_components/ember/ember-template-compiler.js');
to the top level of my project directory in the Brocfile.js.
ember build
Future versions of Ember CLI will not support v0.10.33. Please update to Node 0.12 or io.js.
version: 0.2.5
A new version of ember-cli is available (0.2.6). To install it, type ember update.
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/#watchman for more info.
Building..
controllers/application.js: line 1, col 16, 'Ember' is not defined.
1 error
===== 1 JSHint Error
Warning: ignoring input sourcemap for bower_components/ember/ember-template-compiler.js because ENOENT, no such file or directory 'proj/tmp/tree_merger-tmp_dest_dir-HJiSoIdK.tmp/bower_components/ember/ember-template-compiler.map'
Is there a separate build step that I am missing to create the template compiler map as the last warning fails create the necessary source map?
I just installed WebStorm. I'm working on a small Node.js app.
I've attached the Node.js source code, and when I click on the Node.js settings, I can see that it can recognize my various node modules, etc.
I'm having two issues:
Unresolved variable or type: WebStorm doesn't seem to recognize simple API methods (exports, require).
No code insight for…: If I call require('winston'), it tells me that it has no code insight. (Is there a way I can add the source code?)
For 2018 and later versions of WebStorm:
In Settings -> Languages & Frameworks -> Node.js and NPM, check Coding assistance for Node.js:
In older Webstorm versions, this was called Enable Node.js Core library.
If you still see unrecognized Node symbols even with that option enabled, unckeck it, restart WebStorm, then right click on the warning and choose Enable Node.js coding assistance or just check the option again. Watch for WebStorm to show it's Indexing files. (Just had this happen today - looks like a WebStorm bug, and what I just wrote fixed the situation.)
For WebStorm 7 thru 10 (on OSX)…
WebStorm → Preferences → Languages & Frameworks → Javascript → Libraries
Select "Node.js Globals" and "Node.js vXXX Core Modules".
I use WebStorm 2020 and I had everything enabled but WebStill though showed that module.exports is unknown function. Then I turned off NodeJS.core library and NodeJS code assistance, applied and then turned them on again. And suddenly it started to work.
As I've answered on the WebStorm says console is an unresolved variable question, to solve these problems on the new Webstorm versions, you need to enable the Coding assistance for Node.js.
To do this, go on the Settings > Languages & Frameworks > Node.js and NPM and click on the Coding assistance for Node.js option, and then click OK to save:
This will all Node.js unresolved variables and functions.
Update
On the new Webstorm versions, just going above error and clicking in More Actions... (or ALT+ENTER) and selecting
Enable Node.js coding assistance will solve this.
Working with WebStorm and Node.js these two code-segments regularly gave me "false positive" warnings:
FALSE POSITIVE WARNING CASE 1:
module.exports = ...
That gave me the warning "Element is not exported". I was able to get rid of the warning caused by that by putting this above the "module.exports = ..."
/** #namespace module.exports **/
FALSE POSITIVE WARNING CASE 2:
let something = global.something ;
That gave me the warning "Unresolved variable or type global". I was able to eliminate the warning caused by that by putting this above it:
/** #namespace global **/
I now put the following on top of my .js- or .mjs-files to be executed by Node.js, and get rid of warnings referring to these variables or properties:
/** #namespace global **/
/** #namespace console **/
/** #namespace process **/
/** #namespace Buffer **/
/** #namespace process.stdin **/
/** #namespace module.exports **/
I am using WebStorm 2022.2.3
Updating to Webstorm 8 or higher will fix your require methods problem. As posted earlier by checking if Settings > JavaScript > Libraries > Node.js are all checked will fix your problem