V
V
Vadym Masiuk2020-08-12 19:04:02
Node.js
Vadym Masiuk, 2020-08-12 19:04:02

Using node_modules from another project folder?

Good afternoon!
Interested in how you can use a module (for example, WebPack) from a folder one level (or several levels) higher?
For example, there is a structure
C:\projects\
----node_modules\
----project1\
--------subfolder\
------------node_modules\
----- -------package.json, which contains the following lines:
"scripts": {
"test": "webpack"
},
----package.json

When you enter the command in the console: npm run test, an error pops up "webpack is not recognized as an internal or external command..."

WebPack is located in C:\projects\node_modules\, how can I use it with a project in C:\projects\project1\subfolder\?

Thanks in advance

Answer the question

In order to leave comments, you need to log in

2 answer(s)
V
Vadym Masiuk, 2020-09-02
@7TyLe

Well, actually, I’ll answer myself: this is impossible without explicitly specifying the path to the module (

A
Alexey Yarkov, 2020-08-12
@yarkov

Well, and register the path to the executable file. Something like this:
"test": "../../node_modules/.bin/webpack"

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question