简体   繁体   English

在 Hostinger 共享主机上安装 Node.js 的问题

[英]Issue with installing Node.js on Hostinger shared-hosting

I have installed Node.js on my Hostinger shared-hosting according to https://medium.com/@mayomi1/how-to-host-a-node.js-app-on-shared-host-52e12a62a259 .我已经根据https://medium.com/@mayomi1/how-to-host-a-node.js-app-on-shared-host-52e12a62a259 在我的 Hostinger 共享主机上安装了 Node.js

When I try to use npm install fibers or npm install from the following package.json.当我尝试使用 npm 安装光纤或 npm 从以下 package.json 安装时。

{
  "name": "mekkaniko",
  "version": "1.0.0",
  "description": "Nuxt Express WebApp",
  "author": "iotronlab",
  "private": true,
  "scripts": {
    "dev": "cross-env NODE_ENV=development nodemon server/index.js --watch server",
    "build": "nuxt build",
    "start": "cross-env NODE_ENV=production node server/index.js",
    "generate": "nuxt generate"
  },
  "dependencies": {
    "nuxt": "^2.0.0",
    "cross-env": "^5.2.0",
    "express": "^4.16.4",
    "@nuxtjs/axios": "^5.3.6",
    "@nuxtjs/pwa": "^3.0.0-0"
  },
  "devDependencies": {
    "nodemon": "^1.18.9",
    "@nuxtjs/vuetify": "^1.0.0",
    "eslint-config-prettier": "^4.1.0",
    "eslint-plugin-prettier": "^3.0.1",
    "prettier": "^1.16.4"
  }
}

I get the error log我收到错误日志

1404 verbose stack Error: fibers@4.0.1 install: `node build.js || nodejs build.js`
1404 verbose stack spawn ENOENT
1404 verbose stack     at ChildProcess.<anonymous> (/home/u363303914/.nvm/versions/node/v12.8.1/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
1404 verbose stack     at ChildProcess.emit (events.js:203:13)
1404 verbose stack     at maybeClose (internal/child_process.js:1021:16)
1404 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
1405 verbose pkgid fibers@4.0.1
1406 verbose cwd /home/u363303914/domains/mekkaniko.com/public_html
1407 verbose Linux 3.10.0-962.3.2.lve1.5.25.10.el7.x86_64
1408 verbose argv "/home/u363303914/.nvm/versions/node/v12.8.1/bin/node" "/home/u363303914/.nvm/versions/node/v12.8.1/bin/npm" "install" "fibers"
1409 verbose node v12.8.1
1410 verbose npm  v6.10.2
1411 error file sh
1412 error code ELIFECYCLE
1413 error errno ENOENT
1414 error syscall spawn
1415 error fibers@4.0.1 install: `node build.js || nodejs build.js`
1415 error spawn ENOENT
1416 error Failed at the fibers@4.0.1 install script.
1416 error This is probably not a problem with npm. There is likely additional logging output above.
1417 verbose exit [ 1, true ]

Follow these steps:按着这些次序:

wget -qO- https://cdn.rawgit.com/creationix/nvm/master/install.sh | bash

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

nvm install node
nvm use node

Updated version:更新后的版本:

The other answer provides a good starting point but it is outdated and the versions 18 and 19 will return errors, including:另一个答案提供了一个很好的起点,但它已经过时,版本 18 和 19 将返回错误,包括:

GLIBC_2.27 not found找不到 GLIBC_2.27

The way I managed to make it work is:我设法使其工作的方式是:

wget -qO- https://cdn.rawgit.com/creationix/nvm/master/install.sh | bash

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"

nvm install 16

Then you will be using node version 16 and will not return any errors.然后您将使用节点版本 16,并且不会返回任何错误。

In case you get the error如果你得到错误

Permission denied on laravel mix laravel mix 权限被拒绝

A simple rebuild will fix it:一个简单的重建将修复它:

npm rebuild

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM