GoogleChromeLabs / ndb

ndb is an improved debugging experience for Node.js, enabled by Chrome DevTools

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Running with node 14 and babel

ayouubkhial opened this issue · comments

I'm using node 14 and ndb version 1.1.5 installed globally.
Here's package.json

{
    "name": "movify",
    "version": "1.0.0",
    "main": "src/app.js",
    "scripts": {
        "start": "nodemon --exec babel-node ./src/app.js",
        "debug": "ndb babel-node ./src/app.js"
    },
    "author": "",
    "license": "ISC",
    "devDependencies": {
        "@babel/cli": "^7.10.4",
        "@babel/core": "^7.10.3",
        "@babel/node": "^7.10.3",
        "@babel/preset-env": "^7.10.3",
        "nodemon": "^2.0.4"
    }
}

When I run npm start everything works fine and the server runs successfully.

C:\Users\21262\Desktop\movify>npm start

> movify@1.0.0 start C:\Users\21262\Desktop\movify
> nodemon --exec babel-node ./src/app.js

[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `babel-node ./src/app.js`
Server running in development mode on port 3000
MongoDB connected: movify

But when I run npm run debug the terminal get stuck in nodemon --exec babel-node ./src/app.js:

C:\Users\21262\Desktop\movify>npm run debug

> movify@1.0.0 debug C:\Users\21262\Desktop\movify
> ndb babel-node ./src/app.js

I was able to solve this problem by generating the new code source using babel and run it through ndb.
My package.json scripts:

"scripts": {
	"start": "nodemon --exec babel-node ./src/app.js",
    "clean": "rm -rf dist",
    "build": "npm run clean && mkdir dist && babel ./src -s -d ./dist",
    "serve": "SET NODE_ENV=production && node ./dist/app.js",
    "debug": "npm run build && ndb ./dist/app.js"
}

Now when I run npm run debug I got the following error: regeneratorRuntime is not defined
So I had to install @babel/plugin-transform-runtime package and change add it as a plugin in babel.config.json file:

{
    "presets": ["@babel/preset-env"],
    "plugins": ["@babel/plugin-transform-runtime"]
}