官术网_书友最值得收藏!

Installing dependencies

[root@awsstar example-node-server]# yarn install 
yarn install v0.27.5
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
warning fsevents@1.1.2: The platform "linux" is incompatible with this module.
info "fsevents@1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 8.18s.

Build the application by hitting yarn run build, once the build happens, we get the dist folder:

[root@awsstar example-node-server]# yarn run build
yarn run v0.27.5
$ babel lib -d dist
lib/index.js -> dist/index.js
Done in 0.43s.
[root@awsstar example-node-server]# ls
dist lib node_modules package.json test yarn.lock
[root@awsstar example-node-server]# ls dist
index.js

It's time to run the server and access the application:

[root@awsstar example-node-server]# yarn serve
yarn serve v0.27.5
$ node dist/index.js
Server running at http://127.0.0.1:1337/

Check the test case by hitting yarn test:

[root@awsstar example-node-server]# yarn test
Server running at http://127.0.0.1:1337/
Example Node Server
? should return 200
1 passing (43ms)

We can also use npm instead of yarn for building the NodeJS application. In the next example, I have used npm to build the NodeJS application using CodeBuild.

主站蜘蛛池模板: 天门市| 堆龙德庆县| 宜黄县| 昆山市| 徐水县| 浦东新区| 罗城| 襄汾县| 龙口市| 且末县| 正安县| 临海市| 昌乐县| 固阳县| 辽宁省| 醴陵市| 吉隆县| 荥经县| 明水县| 大悟县| 马边| 永康市| 信宜市| 泗水县| 兴海县| 招远市| 中江县| 弥渡县| 萝北县| 石家庄市| 延庆县| 龙泉市| 平顶山市| 集安市| 合肥市| 故城县| 宁强县| 清原| 前郭尔| 克什克腾旗| 辽阳县|