Questions tagged [babel-node]
80 questions
2
votes
2 answers
Can't run global babel-node in es2015 mode
so when I install these packages locally they work, but when installed globally (and removed them locally)
npm i babel-cli -g
npm i -g babel-preset-es2015
npm i -g babel-preset-es2015-node
seems like that flag isn't setting es2016-node to look…

user2167582
- 5,986
- 13
- 64
- 121
2
votes
3 answers
Why does this code not result in a ReferenceError?
if(true) {
tmp = 'abc';
console.log(tmp);//which should throw referenceError but not
let tmp;
console.log(tmp);
tmp = 123;
console.log(tmp);
}
This code results in
abc
undefined
123
Why does the first console.log(tmp) not throw an…

Runjuu
- 43
- 5
1
vote
0 answers
Nodejs Babel TypeError: Cannot read properties of undefined (reading 'default')
I'm using babel to transpile es6 code to es5. I have this mongoose model
// src/user.model
const User = mongoose.model('User', userSchema);
export default User;
used in this index.js file within the same folder
// src/index.js
import User from…

ostheperson
- 11
- 3
1
vote
0 answers
@babel/node@7.16.8 with express throws exception in NODE v.8
Very strange problem I run into, may be someone know what problem is:
This problem observed during test in Node v.8.12.0 In Node v>14 everything is OK. (Don't ask me why v.8 is still important.. Yes, we are still there in some apps :-(( )
Super…

Vitaliy Markitanov
- 2,205
- 1
- 24
- 23
1
vote
1 answer
Why does babel-loader fail but babel-node works fine mixing ES imports and CJ modules?
I have files in my project which use both CJS require and ES import syntax, like such:
const multer = require('multer');
import multerS3 from './multer-s3-storage-engine.js';
const ExpressRouter =…

volume one
- 6,800
- 13
- 67
- 146
1
vote
1 answer
How to make ts-node aware of a namespace declared in a `d.ts` file?
I have a MY_FILE.ts file like that:
const someFunction = (param: MY_NAMESPACE.PARAM) : boolean => { // DO SOMETHING };
The param type is accessed through a namespace called MY_NAMESPACE that I declare on a MY_NAMESPACE.d.ts file. Like…

cbdeveloper
- 27,898
- 37
- 155
- 336
1
vote
1 answer
babel-node is compiling test and failing
I can build and the code works and correctly excludes the tests using and can run the code with node:
babel src -s -d dist --extensions ".js,.ts,.tsx" --ignore '**/*.test.js' --ignore '**/test/*'
But trying to use babel-node seems to include the…

pogson
- 11
- 1
1
vote
0 answers
babel v7 upgrade causing unexpected token import in files imported by related path and in plugin-transform-runtime
After upgrading to 7 none of the googled answers not working.
I have a project structure
package.json
"scripts": {
"start": "yarn dev:start",
"restart": "touch src/shared/app.jsx",
"dev:start": "cross-env BABEL_ENV=dev nodemon -e js,jsx…

webdevMerlion
- 11
- 2
1
vote
3 answers
Variable becomes undefined when access in a class method
I defined a class variable in a constructor which holds a reference to an imported class instance.
However, when I try to access the variable in my class methods I keep getting undefined for that variable.
Exported class
import models from…

wokoro douye samuel
- 2,194
- 3
- 15
- 29
1
vote
2 answers
Using external babel configuration
I'm using @babel/node package in my project
and when I run my project as:
npm run dev
I'm getting this message in cmd window:
> Using external babel configuration
> Location: "...(project folder path)\.babelrc"
And when I build my project jsx…

Masoud Sadeghi
- 357
- 3
- 15
1
vote
1 answer
How to import es6 modules with babel-node?
I have some trouble with writing a quick test for my node express application. The problem is: in my server's file I use es6 import to import my custom class. So there is a line like this:
import MyClass from 'src/myclass.js';
my test script look…

Kostyuk Rostyslav
- 367
- 2
- 16
1
vote
1 answer
Setup WebStorm + Node.js + nodemon + babel-node
My configuration in WebStorm looks like this:
and it fails with
[nodemon] 1.18.10
[nodemon] to restart at any time, enter `rs`
[nodemon] watching: *.*
[nodemon] starting `babel-node server.js`
[nodemon] unable to run executable:…

Diolor
- 13,181
- 30
- 111
- 179
1
vote
0 answers
Why can't @babel/node find a local file for an import?
I'm working on a small project to get more familiar with setting up a Node project and running it. I'd like to write it in ES6 and run it through an NPM script, so I installed the following libraries:
"@babel/cli": "7.2.3",
"@babel/core":…

Karl Thompson
- 65
- 1
- 7
1
vote
3 answers
spawn babel-node ENOENT
I am building a react app from scratch with yarn and not npm as yarn is fast than npm. I am not using create-react-app command to create my react app just to make sure I do everything from scratch.
I have a webpack file with basic configuration…

ggorantala
- 196
- 2
- 16
1
vote
0 answers
Double dash in Centos vs OSx shebang
I have the following ./run file with +x mode.
#!/usr/bin/env babel-node --
require("generator/run.js")
which serves as a entry point for a task manager (for a static site generator).
I call it like $ ./run someTask --someFlag and it works just fine…

Ivan Kleshnin
- 1,667
- 2
- 21
- 24