G
G
g0lovachlena2019-08-02 02:26:30
Node.js
g0lovachlena, 2019-08-02 02:26:30

Why can't node js see installed npm packages?

Hello, I'm not sure that I correctly formulated the question, there was such a problem. I'm trying to install an npm package, let's say postcss, the installation is successful, everything is fine, but as soon as I try to run this package, the console gives a bash error: <package name>: command not found. And so with all packages. It doesn't matter if I install the package globally or locally. Please tell me what could be the problem?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Belyaev, 2019-08-02
@g0lovachlena

Option 1:

PATH="$PWD/node_modules/.bin:$PATH" postcss --params

Option 2:
write the command in the scripts section of package.json and run it via npm run
{
  "scripts": {
    "postcss": "postcss --params"
  }
}
npm run postcss
option 3:
run the package via npx, this does not even require installationnpx postcss --params

M
McBernar, 2019-08-02
@McBernar

Install the package locally and run it from the folder where you installed it. Accordingly, do not forget to init npm.
If it works, dig for information about global paths in the system.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question