Windows node bin path

Исправление пути npm в Windows 8 и 10

много гуглил, пробовал переустановить узел.в JS с помощью официального установщика, но мой НПМ маршруты по-прежнему не работает.

это не работает

Я получаю сообщение об ошибке говоря отсутствует модуль npm-cli.js

2 часа гуглить позже я обнаружил обходной путь
А не просто’npm‘ я типа

но как я могу исправить свою установку nodejs, чтобы я мог просто ввести «npm»?

8 ответов:

вам нужно добавить C:\Program Files\nodejs к переменной среды PATH. Для этого выполните следующие действия:

  1. используйте глобальный поиск очарование для поиска «Переменные среды»
  2. Нажмите кнопку «изменить системные переменные среды»
  3. нажимаем «Переменные среды» в диалоговом окне.
  4. в поле» системные переменные » найдите путь и отредактируйте его, чтобы включить C:\Program Files\nodejs . Убедитесь, что он отделен от любых других путей с помощью ; .

вы придется перезапустить все открытые в настоящее время командные подсказки, прежде чем он вступит в силу.

npm config get prefix

и просто в качестве будущей ссылки, это путь, который я добавил В Windows 10:

зайдите в Панель управления -> Система -> Дополнительные параметры системы переменные среды.

отсюда найдите переменную path, перейдите в конец строки и вставьте «C:\Program Files\nodejs\node_modules\npm\bin «(измените путь к каталогу, в котором вы его установили, например, если вы специально установили его в любом месте, измените его)

Я использую Windows 10 — 64 бита, поэтому я бегу. Команды:

  • NVM arch 64 (чтобы сделать по умолчанию 64-разрядный исполняемый файл)
  • список nvm (чтобы перечислить все доступные версии узлов)
  • nvm установить 8.0.0 (для загрузки узла версии 8.0.0-вы можете выбрать любой)
  • nvm использовать 8.0.0 (чтобы использовать этот конкретный версия)

в моем случае мне пришлось просто переключиться на версию 8.5.0 а затем снова переключиться на 8.0.0 и это было исправлено. По-видимому, NVM устанавливает переменные пути всякий раз, когда вы делаете этот переключатель.

Я использовал командлет и перейдите к пути, на который вы хотите переключить файлы npm. Введите npm root-g чтобы узнать, на какой текущий путь установлен ваш npm. Следующее использование npm config set prefix и ваш путь npm будет изменен на любой каталог, в котором вы сейчас находитесь.

попробуйте этот чувак, если вы используете Windows:

1.) Поиск переменных среды в поле поиска меню Пуск.
2.) Нажмите на него, а затем перейдите к Environment Variables.
3.) Нажмите путь, нажмите кнопку Edit
4.) Нажмите новая и попробуйте скопировать и вставить это: C:\Program файлы\nodejs\node_modules\npm\bin

если вы получили сообщение об ошибке. Число 4.) Нажмите кнопку Создать, а затем просмотрите bin папка

  • вы также можете посетить этой ссылке для получения дополнительной информации.
Читайте также:  Звук по hdmi с видеокарты windows 10

Это сработало для меня: 1. npm root-g (чтобы увидеть текущий npm установлен) 2. npm config set prefix (изменить путь)

У меня была эта проблема на 2 компьютерах в моем доме, используя Windows 10 каждый. Проблема началась, когда мне пришлось изменить несколько переменных среды для проектов, над которыми я работал в Visual studio 2017 и т. д. Через несколько месяцев, вернувшись к использованию node js и npm, у меня снова возникла эта проблема, и не помогли решения выше. Я видел комментарий Шона к решению Яра, и я смешал оба решения: 1) в окне переменные среды у меня была одна дополнительная переменная, которая содержала это значение: %APPDATA%\npm. Я удалил его, и проблема исчезла!

Как настроить переменные окружения (NODE_PATH)?

Постоянно сталкиваюсь с проблемой NODE_PATH
К примеру, в package.json прописано

Сборка спотыкается на NODE_PATH
«NODE_PATH не является внутренней или внешней командой, исполняемой программой. «

Как я понимаю проблема в том, что сборка писалась на UNIX системах, а у меня Виндоус.
Нужно задать переменные окружения
Вроде задал

Но не помогает.

  • Вопрос задан более трёх лет назад
  • 15159 просмотров

Каждое значение в scripts — это, по сути, скрипт операционной системы. Все верно, написаны они для *nix, и под виндой работать не будут даже при всех переменных окружения, потому что конструкция типа NODE_PATH=$NODE_PATH:./shared не является валидной для виндового интерпретатора командной строки. Надо исправить на что-то такое: SET NODE_PATH=%NODE_PATH%;.\shared . Скорее всего, путь к папке shared должен быть абсолютным.
Команду build надо поменять как-то так:

Другие способы:
1) сделать форк, написать на JS кросс-платформенные скрипты, которые запускают нужные вещи с нужными параметрами, положить их в папку bin проекта и послать pull-request
2) одуматься и перейти на линукс.

Should I add

/node_modules/.bin to my $PATH #957

Should I add

Comments

timoxley commented May 22, 2011

local as default is really frustrating, just wondering if adding

/node_modules/.bin to my path would fix me having to use -g EVERY time i install a module that comes with a commandline tool?

The text was updated successfully, but these errors were encountered:

isaacs commented May 22, 2011

You can add whatever folder to your path that you like 🙂

Of course, then it’ll only work if you do a local install in

. If you’re in some other folder, it won’t put the bin in

/node_modules. But, you could put node_modules/.bin in your PATH, and then you’ll be able to use the bins installed in that folder when you’re in that folder.

airtonix commented Apr 22, 2014

I know this is an old ticket, but it shows up on google for «npm which PATH», so I thought I’d leave my work around here.

This only works on sh, bash, zsh (pretty much any shell that uses

disclaimer: it’s ugly, but it makes using node_modules/.bin easy.

greypants commented Oct 29, 2015

Another solution is to use the scripts property in package.json and npm run yourthing instead. npm run first looks for scripts local to that folder in node_modules/.bin

Читайте также:  Тех поддержка linux пользователей

You can still pass arguments too:

No more global installs evar.

shyam-habarakada commented May 19, 2016

A cleaner solution, as someone pointed out in stack overflow is to simply update your path as,

This limits you to finding the binaries only while running commands from a project root directory (or the same parent folder as node_modules) but it seems better than other solutions that involve running script on PROMPT_COMMAND, etc.

airtonix commented May 19, 2016

No. You should use either nvm or nodist.
You should then be using the scripts feature of your package.json.

If you’re using nvm then you should be using autoenv.

Don’t mess with your path at runtime, is not reproducible, not robust and
you can’t predict how it will pan out on other systems.

On Fri, 20 May 2016, 07:10 shyam-habarakada notifications@github.com
wrote:

A cleaner solution, as someone pointed out in stack overflow is to simply
update your path as,

This limits you to finding the binaries only while running commands from a
project root directory (or the same parent folder as node_modules) but it
seems better than other solutions that involve running script on
PROMPT_COMMAND, etc.


You are receiving this because you commented.
Reply to this email directly or view it on GitHub
#957 (comment)

NPM : how to source ./node_modules/.bin folder?

I have a problem on npm installation

I have created a project say project A

but sails command is not found after installation.

I know that it is successfully install in

/projectA/node_modules directory. but the executable cannot be sourced. And i know it is installed

How can I source the .bin automatically whenever I enter into this projectA folder?

Did I did something wrong?

/projectA/node_modules/.bin and not

/projectA/node_modules/sails/bin instead? What do you mean by source? – verybadalloc Aug 4 ’13 at 1:00

8 Answers 8

I can give you an inelegant solution, which is working for me. I just exported my path in my .bashrc file.

Edit: It’s been a while, but I have changed my strategy to use npm scripts instead. In the above case, setup package.json as follows:

Which you can then run with

or with arguments

You should use the npm bin command to get an absolute path to your current node bin directory.

This avoids the problem of relative paths, especially if you’re going to be using this in a build system that will invoke the command in subdirectories.

A bit more robust is:

You can either run it, add it to your shell profile, or create an alias like:

If you do go the alias route, be sure to use single quotes so it delays the execution of the variables!

To use on the command line like sails generate foo you will need to install the npm module globally.

Читайте также:  Клавиатура apple при установке windows

You could also use the path to the bin in the command if you don’t want to install globally:

The official instructions for sails (https://github.com/balderdashy/sails) advises

To install the latest stable release with the command-line tool:

This installs globally and adds to a directory like /usr/local/bin that should be in your $PATH .

But to answer the general question regarding the location of the binaries if you install locally, they should be placed in ./node_modules/.bin directory (so run ./node_modules/.bin/sails . )

Global npm install location on windows?

I’m not 100% sure, but I believe I installed node v5 from the windows installer on both my home and office PCs.

On my home PC global installs happen under %APPDATA%:

while on my office PC, they go under program files:

I need to provide the full path to a number of these global tools to PyCharm’s file watcher, and since the project file i shared it would make sense to not have global resources under a user folder.

Why would the global installs end up in different folders, and how can I force them to a location that is common to all team members?

4 Answers 4

  • Local install (default): puts stuff in ./node_modules of the current package root.
  • Global install (with -g): puts stuff in /usr/local or wherever node is installed.
  • Install it locally if you’re going to require() it.
  • Install it globally if you’re going to run it on the command line. -> If you need both, then install it in both places, or use npm link.

prefix Configuration

The prefix config defaults to the location where node is installed. On most systems, this is /usr/local . On windows, this is the exact location of the node.exe binary.

The docs might be a little outdated, but they explain why global installs can end up in different directories:

Based on the other answers, it may seem like the override is now the default location on Windows, and that I may have installed my office version prior to this override being implemented.

This also suggests a solution for getting all team members to have globals stored in the same absolute path relative to their PC, i.e. (run as Administrator):

open a new cmd.exe window and reinstall all global packages.

Explanation (by lineno.):

  1. Create a folder in a sensible location to hold the globals (Microsoft is adamant that you shouldn’t write to ProgramFiles, so %PROGRAMDATA% seems like the next logical place.
  2. The directory needs to be on the path, so use setx .. /M to set the system path (under HKEY_LOCAL_MACHINE). This is what requires you to run this in a shell with administrator permissions.
  3. Tell npm to use this new path. (Note: folder isn’t visible in %PATH% in this shell, so you must open a new window).
Оцените статью