You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

在虚拟主机上为Laravel安装Node.js遇问题求助

Fixing Node.js/NVM Issues on Shared Hosting for Laravel

Hey there, let's work through this Node.js/NVM issue you're hitting on your shared hosting for your Laravel project—you mentioned you got it working a year ago, so we can definitely get things sorted again!

First, Let's Break Down the Root Problems

Your error log points to two main roadblocks:

  1. System Library Version Mismatch: The Node.js version you tried (v10.2.1) needs newer versions of GLIBC and GLIBCXX than your shared hosting provides. Shared hosts almost never let you upgrade system-level libraries, so we'll need to pick a Node version that plays nice with your host's existing setup.
  2. NPM Prefix Conflict: NVM is throwing an error because your npm prefix config is set to an empty value, which clashes with how NVM manages Node installations.

Step 1: Clean Up the Broken Node Installation

First, let's remove the incompatible Node version you tried to install:

nvm uninstall v10.2.1

Step 2: Install a Node Version Compatible with Your Host's Libraries

Older Node.js versions have lower system library requirements. For hosts running older OSes (like CentOS 6), Node.js 8.17.0 is a reliable choice—it's the final LTS release of Node 8 and works with older GLIBC/GLIBCXX versions.

Install it via NVM:

nvm install 8.17.0

Set it as your default Node version so it loads automatically whenever you log in:

nvm alias default 8.17.0

Step 3: Fix the NPM Prefix Conflict

After installing the compatible Node version, run the command NVM suggested to resolve the prefix mismatch:

nvm use --delete-prefix 8.17.0

To make this fix permanent, add this line to your ~/.bashrc or ~/.bash_profile file (whichever your host uses for shell configurations):

nvm use 8.17.0 > /dev/null 2>&1

Step 4: Verify Everything Works

Check if Node and npm are functioning correctly:

node -v
npm -v

You should see output like v8.17.0 for Node and a corresponding npm version (around 6.13.4). Once that's confirmed, you can run Laravel's asset commands like npm run watch directly on your host.


Alternative: Go Back to Your Original Working Method

If you still run into snags with hosting-side Node, remember your original approach was totally valid:

  • Compile all your Laravel assets locally using npm run dev (for development) or npm run prod (for production)
  • Upload the compiled files from your local public/css and public/js directories to your virtual host
  • This way, you don't need Node.js installed on the host at all—all the heavy lifting happens on your local machine

内容的提问来源于stack exchange,提问作者OurBG

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.29 07:09:09