I am trying to generate TypeScript definition file (.d.ts) from JavaScript file (*.js)...It has converted all the files expect on Java Script file which contains the following statement
return Java.type('com.test.TestExample').START_ELEMENT
Error Message:
ReferenceError: Java is not defined
at Function.get ATTRIBUTE [as ATTRIBUTE] (eval at <anonymous> (C:\Users\uuk\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:71:64), <anonymous>:95:27)
at getResult (C:\Users\uuk\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:148:47)
at getTopLevelDeclarations (C:\Users\uuk\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:124:17)
at Object.generateIdentifierDeclarationFile (C:\Users\uuk\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\index.js:68:20)
at Object.<anonymous> (C:\Users\uuk\AppData\Roaming\npm\node_modules\dts-gen\bin\lib\run.js:71:24)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
Can you please tell me what is this issue and how to fix this?
Related
I want to use an exported constant from a JS module. My simple script is like
#!/usr/bin/env node
const pi = require('./custom_math').pi
console.log(pi)
But the module I require has an import, so It raises the following error:
$ ./script.js
<path_to_module>/index.js:1
import anotherconstant from '<other_module>'
^^^^^^
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1031:15)
at Module._compile (node:internal/modules/cjs/loader:1065:27)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (./script.js:3:12)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
How can I make a script that uses the pi constant from the simple_math/index.js file?
I have a JavaScript application that is bundled into a client-side application and run in the browser.
An old version of the application used to have a variable assignment like this:
const API_ROOT_URL = `http://${window.location.hostname}:8000/`;
This would presumably get interpolated in the browser.
However, this code now throws a webpack error on webpack 4.42.0:
ReferenceError: window is not defined
at Object.<anonymous> (/usr/src/app/src/client_config.js:4:32)
at Module._compile (/usr/src/app/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (/usr/src/app/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/usr/src/app/webpack.config.js:1:99)
at Module._compile (/usr/src/app/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (/usr/src/app/node_modules/webpack-cli/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at WEBPACK_OPTIONS (/usr/src/app/node_modules/webpack-cli/bin/utils/convert-argv.js:114:13)
at requireConfig (/usr/src/app/node_modules/webpack-cli/bin/utils/convert-argv.js:116:6)
at /usr/src/app/node_modules/webpack-cli/bin/utils/convert-argv.js:123:17
at Array.forEach (<anonymous>)
at module.exports (/usr/src/app/node_modules/webpack-cli/bin/utils/convert-argv.js:121:15)
at /usr/src/app/node_modules/webpack-cli/bin/cli.js:71:45
at Object.parse (/usr/src/app/node_modules/yargs/yargs.js:567:18)
at /usr/src/app/node_modules/webpack-cli/bin/cli.js:49:8
at Object.<anonymous> (/usr/src/app/node_modules/webpack-cli/bin/cli.js:366:3)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/usr/src/app/node_modules/webpack/bin/webpack.js:156:2)
It seems that the interpolation is happening at the time the bundle is created, when window doesn't exist.
Can I get the intended behavior?
I'm trying to run node app server.js with the imported code from GitHub but getting below error in the console. Not sure why I'm getting this error.
Error :util.js:959 Object.setPrototypeOf(ctor.prototype, superCtor.prototype);
TypeError: Object.setPrototypeOf called on null or undefined
at Function.setPrototypeOf (native)
at Object.exports.inherits (util.js:959:10)
at Object.<anonymous> (businessvalidationexception.js:1:17)
at Module._compile (module.js:541:32)
at loader (/home/vagrant/Desktop/..../node_modules/babel-core/node_modules/babel-register/lib/node.js:126:5)
at Object.require.extensions.(anonymous function) [as .js] (/home/vagrant/Desktop/..../node_modules/babel-core/node_modules/babel-register/lib/node.js:136:7)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
I tried to run a node app that I've cloned from
https://github.com/jensoleg/mongoose-timeseries
So I just cloned it and npm install and dependencies but when I ran an example file it gives this error! I've looked at the core code but I don't know what is the problem exactly.
mti.init('test', {interval: 1}); //second: Boolean, minute: Boolean
^
TypeError: undefined is not a function
at Object.<anonymous> (/Users/Kanin/Desktop/test/test.js:7:5)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Function.Module.runMain (module.js:501:10)
at startup (node.js:129:16)
at node.js:814:3
I was trying to use a javascript script to tidy up my itunes library.
My system is windows 8. I am running my javascript file with node.
c:\Users\SaythandBec\Desktop>node RemoveDeadTracks.js
c:\Users\SaythandBec\Desktop\RemoveDeadTracks.js:46
var iTunesApp = WScript.CreateObject("iTunes.Application");
^
ReferenceError: WScript is not defined
at Object.<anonymous> (c:\Users\SaythandBec\Desktop\RemoveDeadTracks.js:46:17)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
c:\Users\SaythandBec\Desktop>
Is there anyway to get wscript to run so I can execute the script?