No se puede instalar NodeJS: / usr / bin / env: node: No hay tal archivo o directorio


Estoy intentando instalar NodeJS en mi Ubuntu 14.04 para usar GruntJs.

He leído acerca de Ubuntu manera diferente de hacerlo (problemas?), así que esto es lo que he hecho para instalarlo:

sudo apt-get install npm

sudo npm install -g grunt-cli

Escribiendo grunt después de eso tengo el error:

/usr/bin/env: node: No such file or directory

Así que, he intentado:

curl -sL https://deb.nodesource.com/setup | sudo bash -

sudo apt-get install -y nodejs

sudo apt-get update

Y tratando de nuevo, y aún obteniendo el error, he intentado:

sudo add-apt-repository https://launchpad.net/~chris-lea/+archive/node.js/

sudo apt-get install -y nodejs

Tengo este mensaje:

nodejs is already the newest version.
0 to upgrade, 0 to newly install, 0 to remove and 3 not to upgrade.

Probé una limpieza justo en caso:

sudo apt-get autoremove

Pero no, el error sigue ahí: cuando escribo grunt todavía obtengo /usr/bin/env: node: No such file or directory

¿Qué debo hacer?

Author: KARTHIKEYAN.A, 2014-10-12

15 answers

Encontró la respuesta. En caso de que ayude a alguien, lo publico aquí:

Hacer un enlace simbólico resuelve el problema: ln -s /usr/bin/nodejs /usr/bin/node (Mi agradecimiento y + 1 voto a bodokaiser ).

NOTA: Creo que este post no es un duplicado exacto, porque ese post fue de alguna manera una pregunta de browserify.

 758
Author: Rosamunda,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-05-23 11:47:36

El problema no es con la versión del nodo. En cambio, es la forma en que NodeJS se instala por defecto en Ubuntu. Al ejecutar una aplicación de nodo en Ubuntu, debe ejecutar nodejs somethign.js en lugar de node something.js

Así que el nombre de la aplicación llamada en el terminal es nodejs y no node. Esta es la razón por la que existe la necesidad de un enlace simbólico para simplemente reenviar todos los comandos recibidos como node a nodejs.

ln -s /usr/bin/nodejs /usr/bin/node
 101
Author: Muhammad bin Yusrat,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-05-06 20:42:36

Creo que deberías actualizar la última versión del nodo

sudo npm cache clean -f
sudo npm install -g n
sudo n stable
 43
Author: vanlan228,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2014-10-12 01:26:29

Si puede acceder a node en la terminal de ubuntu usando el comando nodejs, entonces este problema se puede resolver simplemente usando - crear un enlace simbólico de nodejs y node usando

ln -s /usr/bin/nodejs /usr/bin/node

Y esto puede resolver el problema

 28
Author: Hiro,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-02-09 18:10:27

En mi caso, instalando nodejs-legacy resolvimos el problema.

sudo apt-get install nodejs-legacy
 24
Author: Suleyman Arslan,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-02-16 22:00:38

Solo hazlo

$ sudo apt-get install nodejs-legacy

Y comenzará a funcionar.

 10
Author: Prabhu Nandan Kumar,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-06-07 10:27:15

He encontrado que esto es a menudo un error de mal nombre, si se instala desde un gestor de paquetes que bin puede ser llamado nodejs por lo que solo tiene que establecer un enlace simbólico como así

ln -s /usr/bin/nodejs /usr/bin/node
 9
Author: Ahmad Awais,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-07-29 09:54:18

Si ya tiene instalado nodejs (verifique con which nodejs) y no desea instalar otro paquete, puede, como root:

update-alternatives --install /usr/bin/node node /usr/bin/nodejs 99
 7
Author: Tom Hale,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-08-03 04:35:04

Cuando estaba usando gulp obtuve este error.

~$ gulp

/usr/bin / env: 'node': No hay tal archivo o directorio

Esto se eliminó ejecutando el siguiente comando, debe tener en cuenta que el directorio /usr/bin tiene todos los permisos.

~$ ln -s /usr/bin/nodejs /usr/bin/node

Esto funciona para mí..

 6
Author: Naveen Gupta,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-10-26 14:54:52

Mientras que ln -s es la solución más fácil obvia, una pieza de explicación:

Debido a un conflicto con otro paquete, el ejecutable de la Los repositorios de Ubuntu se llaman nodejs en lugar de node. Guarda esto. mente como usted está ejecutando el software.

Este consejo aparece al instalar sudo apt-get install nodejs.

Así que alguna otra herramienta conocida (no se lo que hace. Si bien es conocido por los repositorios de ubuntu, no está instalado por defecto en 16.04) ocupa que espacio de nombres.

Habría sido bueno, si Ubuntu hubiera ofrecido un consejo de cómo arreglar esto 'limpiamente', si no haciendo a mano lo que de otra manera haría el paquete. (una colisión sigue siendo una colisión... si+cuándo ocurriría)

 4
Author: Frank Nocke,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2016-10-28 14:46:50

Hay dos soluciones para esto:

A) Establezca su variable PATH para incluir "/usr/local / bin"

export PATH="$PATH:/usr/local/bin"

B) Cree un enlace simbólico a "/ usr / bin " que ya esté en su RUTA

ln -s /usr/bin/nodejs /usr/bin/node

Espero que ayude.

 2
Author: Pavel,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-09-28 08:47:36
sudo PATH="$PATH:/usr/local/bin" npm install -g <package-name>
 1
Author: KARTHIKEYAN.A,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-03-24 11:22:36

Para mi caso link ¿ NO trabajo como siga

Ln-s/usr/bin /nodejs/usr/bin / node

Pero puede abrir /usr/local/bin/lessc como root, y cambiar la primera línea de node a nodejs.

-#!/usr/bin / env node

+#!/usr/bin / env nodejs

 1
Author: Tanvir Ahmad,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2017-12-08 11:00:16

Simplemente cambie el nombre del comando o archivo ln -s /usr/bin/nodejs /usr/bin/node por este comando

 0
Author: Shalauddin Ahamad Shuza,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-04-29 19:44:12

Dependiendo de cómo haya instalado su nodo, la mayoría de las veces podría no estar en /usr/bin/, en mi propio caso fue que usé nvm para instalar para que mi nodo estuviera dentro ./nvm/versiones.

Usando este comando which node encontré la ruta, pero para hacer el trabajo más fácil puede ejecutar este comando.

nodepath=$(which node); sudo ln -s $nodepath /usr/bin/node

El comando anterior obtendrá la ubicación de su nodo y creará un enlace para usted.

 0
Author: akisoft,
Warning: date(): Invalid date.timezone value 'Europe/Kyiv', we selected the timezone 'UTC' for now. in /var/www/agent_stack/data/www/ajaxhispano.com/template/agent.layouts/content.php on line 61
2018-06-03 00:40:31