2015-02-11 7 views
1

Я установил Node на Linux Mint, сделав sudo apt-get install node npm, но он, похоже, не работает вообще. Я создал этот небольшой скрипт, чтобы проверить, если что-то происходит:node - ничего не происходит при запуске скрипта

console.log('this is a test'); 
throw new Error(); 

Когда я исполню ее из терминала, нет абсолютно никакого Ouput: нет журнала, нет ошибки:

[email protected] ~ $ node tests.js 
[email protected] ~ $ 

Каждый знает, как чтобы исправить это?

+2

Что делать, если вы запустите '' node' или npm' сами? – Scimonster

+0

Вы уверены, что Node.js установлен как «узел» в вашей системе? Иногда он устанавливается как «nodejs», где «node» - это другая программа. –

+0

После использования нижеприведенного решения я понял, что вы правы. Мне нужно, чтобы он назывался узлом, иначе uglifyjs не запускался. – user3078230

ответ

2

Попробуйте эти команды, чтобы установить nodejs

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

затем

sudo apt-get install -y nodejs

Теперь запустите скрипт

0
Below are the steps to install Node.js from source (OSX/linux) 

NOTE - this installs Node.js which gives you both node as well as npm, 
     they come together per release. 

to start fresh remove prior node and npm installs as well as these : 

    sudo mv ~/.npmrc ~/.npmrc_ignore 
    sudo mv ~/.npm ~/.npm_ignore 
    sudo mv ~/tmp ~/tmp_ignore 
    sudo mv ~/.npm-init.js ~/.npm-init.js_ignore 

download source from : http://nodejs.org/download/ 

    cd node-v0.12.0 

You may/should issue all following cmds as yourself NOT root (sudo) 

Pick one of these NODE_PARENT locations to define where node gets installed into : 

    export NODE_PARENT=/some/desired/install/path_goes_here 
    export NODE_PARENT=/usr/local/bin/nodejs # use this ONLY if you MUST install as root (sudo) 
    export NODE_PARENT=${HOME}/node-v0.12.0 # Recommended - its owned by you NOT root 

    export PATH=${NODE_PARENT}/bin:${PATH}  # jacks up PATH so executables are found later 
    export NODE_PATH=${NODE_PARENT}/lib/node_modules # so node itself can find its modules dir 

    ./configure --prefix=${NODE_PARENT} 

    make -j8 # if you have quad core use -j8 else -j4 ... it parallelizes make 
    make install 

which puts it into dir defined by above --prefix 

when you use syntax : npm install -g some_cool_module 
the -g for global installs it into dir $NODE_PATH and not your $PWD 

IMPORTANT - put above three export xxx=yyy 
commands into your ~/.bashrc or some such to persist these environment variable changes 

On subsequent updates to Nodejs, just update your ~/.bashrc with new release name in 
your NODE_PARENT env var , then source this ~/.bashrc and simply issue the configure/make/install as above 
Смежные вопросы