Skip to content
    SeaCode
    Learning tracksCode ArenaWorkshops & EventsInstructors
    Log inSign up
    NODENode.js

    Runtime and core tooling

    • What is Node.js?
    • CommonJS and ES modules
    • npm and package.json
    • process and command-line apps

    Async I/O and events

    • Event loop: callbacks to async/await
    • Files and paths with fs/promises
    • EventEmitter
    • Streams and backpressure

    HTTP and APIs

    • Your first HTTP server
    • Routing and JSON bodies
    • Build a tiny router and middleware chain
    • REST: resources and status codes
    • Validation and error handling

    Production: security, testing and deployment

    • Authentication basics with crypto
    • Configuration and environment secrets
    • Testing with assert and node:test
    • API security fundamentals
    • Project: tasks REST API and deployment
    Node.js

    Runtime and core tooling · Lesson 3 of 18

    npm and package.json

    Describe a project, its scripts and dependencies, and lock versions correctly.

    11 minutes2 games

    package.json is the project's manifest: name, version, scripts and dependencies. npm install reads it, installs packages into node_modules, and updates package-lock.json, locking the entire dependency tree so CI and teammates reproduce it.

    package.json: requested ranges

    package-lock: exact tree

    npm ci

    node_modules

    Node.js
    const pkg = {
      name: "seacode-api",
      version: "1.0.0",
      scripts: { start: "node server.js", test: "node test.js" },
      dependencies: {}
    }
    console.log(pkg.name, pkg.scripts.start)

    dependencies are needed at runtime; devDependencies support development and tests. In CI use npm ci: it requires the lockfile to match and performs a clean install. Commit the manifest and lockfile, not node_modules.

    Terminal
    npm init -y
    npm install express
    npm install --save-dev eslint
    npm run test
    npm ci

    Important

    A third-party package's install script is code running on your machine. Review source, reputation and permissions; minimize dependencies, and understand audit findings rather than applying blind upgrades that break the app.

    Quick question

    Which file locks exact versions for the entire tree?

    Interview question

    Difference between npm install and npm ci?

    Exercise

    Write startCommand(pkg) returning its start script or node index.js as fallback, then print both.

    Expected output:
    node api.js
    node index.js
    Node.js
    function startCommand(pkg) {
    
    }
    console.log(startCommand({ scripts: { start: "node api.js" } }))
    console.log(startCommand({}))

    Learn more from

    • npm Docs: package.jsondocs.npmjs.com
    • Node.js: Package manager introductionnodejs.org

    Played 0 of 2 games

    Sign in to save your progress and earn XP.

    PreviousCommonJS and ES modulesNextprocess and command-line apps
    SeaCode

    Learn to code for real, online or at our branch in front of Cairo University, Giza.

    Learn

    • All courses
    • Interactive tutorials
    • Interview practice problems
    • Mock interview
    • Learning tracks
    • Code Arena
    • Workshops & Events
    • Knowledge library
    • Team projects

    Your account

    • Log in
    • Sign up
    • Learning plan
    • Certificates
    • Site map

    Contact us

    • WhatsApp
    • 010 9094 1104
    • In front of Cairo University, Giza

    © 2026 SeaCode. All rights reserved.