I am new in nodejs
framework .I read the tutorial, but I want to know how to create a build in node js, in other words I need a script
which create my build folder.
I follow these steps
- create index.js in root directory add some code.
then add this line of code
import express from 'express'; const app = express();
app.listen(3000,function () { console.log(`app is listening on 3000`) })
in my package.json I added start
and build
script
"scripts": {
"start": "nodemon ./index.js --exec babel-node -e js",
"build": "mkdir dist && babel src -s -d dist"
},
when I do npm run start
.my application run fine and I am able to debug also.
Now I want to deploy this application on production Need build.so how to generate build using babel
when I run npm run build
I am getting error
src doesn't exist
I am new in nodejs
framework .I read the tutorial, but I want to know how to create a build in node js, in other words I need a script
which create my build folder.
I follow these steps
- create index.js in root directory add some code.
then add this line of code
import express from 'express'; const app = express();
app.listen(3000,function () { console.log(`app is listening on 3000`) })
in my package.json I added start
and build
script
"scripts": {
"start": "nodemon ./index.js --exec babel-node -e js",
"build": "mkdir dist && babel src -s -d dist"
},
when I do npm run start
.my application run fine and I am able to debug also.
Now I want to deploy this application on production Need build.so how to generate build using babel
when I run npm run build
I am getting error
src doesn't exist
Share Improve this question asked Nov 26, 2019 at 2:39 user944513user944513 12.8k52 gold badges185 silver badges348 bronze badges 2- you don't need to build it, you simply need to run 'node <your script>.js' – Juliver Galleto Commented Nov 26, 2019 at 2:47
- 1 you need webpack, parcel or rollup to handle bundling your files for you – Juliver Galleto Commented Nov 26, 2019 at 2:49
1 Answer
Reset to default 1You 'build' mand is like 'mkdir ... && babel src ....', then in the photo it does not have a src folder. So you can simply create a src folder and move index.js to src/, or change the mand to 'mkdir dist && babel ./ -s -d dist'. I did not test, but it should work.