![]() |
|
Guide Install npm Packages for a Node.js App on aaPanel - Printable Version +- AdminsForum (https://adminsforum.com) +-- Forum: Free & open-source control panels (https://adminsforum.com/Forum-free-open-source-control-panels) +--- Forum: aaPanel (https://adminsforum.com/Forum-aapanel) +---- Forum: aaPanel Guides & Tutorials (https://adminsforum.com/Forum-aapanel-guides-tutorials) +----- Forum: aaPanel Websites & Web Servers Guides (https://adminsforum.com/Forum-aapanel-websites-web-servers-guides) +----- Thread: Guide Install npm Packages for a Node.js App on aaPanel (/Thread-guide-install-npm-packages-for-a-node-js-app-on-aapanel) |
Install npm Packages for a Node.js App on aaPanel - DEV - 10-14-2026 Installing a Node.js runtime is only the first step. An application may also need packages from npm. This guide installs Express in a separate lab folder on an aaPanel server, fixes a writable-cache problem and verifies a clean lockfile-based installation. npm dependency workflow based on the isolated lab test. Tested: Ubuntu 22.04.5 LTS, aaPanel Free 8.0.7, Node.js 24.21.0, npm 11.19.0 and Express 5.3.0 on 14 October 2026. Commands ran as www in /www/af-npm-lab. This is an SSH workflow, not a demonstration of aaPanel's Module button. The live website was not modified. 1. Confirm the intended Node.js runtime Install Node.js first using the aaPanel runtime guide. Check the Node version supported by your application and dependencies. Use the same intended runtime for package installation and app execution. Our runtime is under /www/server/nodejs/v24.21.0/bin. Replace that path if your installed version differs. A shell's node command can point to a different runtime from the one selected for an aaPanel project. 2. Create a separate practice directory As an administrator over SSH, choose a directory that does not already contain an application: Code: sudo mkdir /www/af-npm-lab
sudo chown www:www /www/af-npm-lab
sudo runuser -u www -- bash3. Set the runtime and a writable npm cache Code: export PATH=/www/server/nodejs/v24.21.0/bin:$PATH
export npm_config_cache=/www/af-npm-lab/.npm-cache
cd /www/af-npm-lab
node --version
npm --versionOur first attempt encountered a shared npm cache at /www/server/nodejs/cache that www could not write to. A separate writable cache fixed the problem without running npm as root or making shared directories writable to everyone. For real deployments, choose a protected cache location outside publicly served files and ensure the intended run user owns it. 4. Initialise only the new sample project Code: npm init -y5. Install the example dependency Code: npm install express --ignore-scripts --registry=https://registry.npmjs.org
npm ls expressWe used --ignore-scripts for this controlled example. Some real packages require installation scripts or build steps; disabling those can leave them unusable. Follow the application's documented requirements rather than applying this flag indiscriminately. 6. Understand the files
7. Verify a clean installation from the lockfile Only run the following in the isolated practice folder: Code: sha256sum package-lock.json
npm ci --ignore-scripts --registry=https://registry.npmjs.org
sha256sum package-lock.json
npm ls expressIf the manifest and lockfile disagree, npm ci reports an error rather than silently updating the lockfile. Resolve that mismatch in a controlled development or build workflow; do not delete the lockfile merely to hide the problem. 8. Check that Node can load the package From the practice directory: Code: node -e 'const express=require("express"); const app=express(); console.log(typeof app.get === "function" ? "EXPRESS_LOAD_PASS" : "FAIL")'npm's audit output reported zero known vulnerabilities during this test. That result is time-dependent and is not a guarantee that a package or application is secure. The lab also displayed a warning about an unknown global --init.module configuration; it did not prevent these checks from passing. 9. Common installation errors
10. Return to aaPanel deployment Type exit to leave the www practice shell. For a real application, prepare dependencies and any required build in a separate release directory, then configure the correct runtime and start command in aaPanel. Restart the intended project and verify its expected response. See Deploy a Node.js app with a domain and HTTPS. Lab result: Express loaded successfully; npm ci passed; the lockfile checksum stayed unchanged. The isolated practice directory is retained. No public application or production dependency update was performed. References: npm ci documentation and Express installation documentation. |