-
Notifications
You must be signed in to change notification settings - Fork 286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Javascript module reference #29
Comments
Hi @rana , do you have moment npm package installed in global or in |
Hi @formulahendry, I love code-runner, very helpful. Hoping to use it more! yes, the library is in 'C:\lab\node_modules\moment'. all node modules present after install. not sure about configuring setting up js with vscode-code-runner. Would be great if there was a little more documentation for JavaScript; otherwise, javascript calls without module references run well. Is this a simple case of user not configuring the tool? Here are some additional questions i would love to see answer in documentation with an example:
Thank you! Rana |
Hi @rana , For question 1, require('some-lib') is supported. Actually, running js with Code Runner has no difference with running your js file as For question 2, do you want to run js with es6 syntax? {
"code-runner.executorMap": {
"javascript": "babel-node"
}
} |
@formulahendry @rana and anyone else who happens along to here, here's how to run your ES6/7 code without having to install "code-runner.executorMap": {
"javascript": "$workspaceRoot/node_modules/.bin/babel-node --harmony $fullFileName"
} The @formulahendry thanks for such a great product - providing the necessary file/folder locations so this can be accomplished is awesome and necessary in a node world where all imports/requires are relative to the file performing the import |
Works faster with
|
Is there an obvious way to run this JavaScript snippet?
--- js code ---
require('moment')
console.log('--- start')
console.log('moment().format(): ', moment().format())
console.log('--- end')
--- output ---
[Running] node "c:\lab\temp-ackikjupmw.js"
--- start
C:\lab\temp-ackikjupmw.js:3
console.log('moment().format(): ', moment().format())
^
ReferenceError: moment is not defined
at Object. (C:\lab\temp-ackikjupmw.js:3:36)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Function.Module.runMain (module.js:575:10)
at startup (node.js:160:18)
at node.js:449:3
[Done] exited with code=1 in 0.189 seconds
The text was updated successfully, but these errors were encountered: