最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - how to create production build in node js? - Stack Overflow

programmeradmin0浏览0评论

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

  1. create index.js in root directory add some code.

  1. 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

  1. create index.js in root directory add some code.

  1. 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
Add a ment  | 

1 Answer 1

Reset to default 1

You '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.

发布评论

评论列表(0)

  1. 暂无评论