Comments (7)
Ah, I see the whole picture now ... because I'm running webpack
which is in the parent, it doesn't know about the webpack-dev-server
. Sorry it is quite obvious.
Well, I would to point that on my local NODE_PATH
is empty by default and to have webpack-dev-server
in child and the rest in parent I need to locate both node_modules
folders.
NODE_PATH="$NODE_PATH:/Users/*****/my/development/parent-app/child-app/node_modules:/Users/*****/my/development/parent-app/node_modules" npm run serve:dev
for reference.
from webpack-cli.
It is a limitation you should have webpack-cli on the same level on webpack-dev-server
from webpack-cli.
I understand that there may be some limits. So if it is meant to work like this it is ok, but I would expect some level of consistency at least in case where webpack
is installed automatically when running npm i webpack-dev-server
, but webpack-cli
doesn't .
from webpack-cli.
Aha, I see your point now @alexander-akait so wouldn't be better to install all dependencies (+ webpack-cli
in my case) automatically or maybe even better, just throw an error with meaningful message and do not install anything, because this is more educative for developers I think. Also I'm thinking about webpack-dev-server
as additional thing/plugin, so it doesn't make sense to install anythig if I'm going to use plugin. It is like because I want to install some Wordpress plugin, the Wordpress will install automatically as a plugin dependecy, this seems to me oposite direction of thinking.
from webpack-cli.
@dominikj111 It is not related to webpack-dev-server, there is a logic and answer why it doesn't work https://github.com/webpack/webpack-cli/blob/master/packages/webpack-cli/src/webpack-cli.ts#L140, no magic, we can't do what you want and no one package can do it - you can't require
/import
package on the parent
level and awating loading it from child
, sorry
Webpack-dev-server is not full featured CLI, it is just a runner for webpack-cli
from webpack-cli.
@alexander-akait I just don't understand why.
And you wrote the apposite direction I'm talking about in this issue. I want to install package in the parent and then I want to require
/import
in the child.
And that really works, I just install express
in the parent and then I did require
in the child and in the child I ran node index.js
and it works.
If I'm wrong, just explain why and we close this issue without resolving it. But from my perspective it is a buggy behavior even there is not problem with running it, but the architecture self I suppose.
from webpack-cli.
Shortly :
- you run
webpack serve
- when you use
webpack serve
,webpack
try to runwebpack-cli
, because webpack itself doesn't have CLI https://github.com/webpack/webpack/blob/main/bin/webpack.js#L106 webpack-cli
in the parent directorywebpack-cli
is running with theserve
command andwebpack-cli
try to findwebpack-dev-server
webpack-cli
can't findwebpack-dev-server
because - looking at the currentnode_modules
directory and up to the top until it will be found https://github.com/webpack/webpack-cli/blob/master/packages/webpack-cli/src/webpack-cli.ts#L140, likerequire
andimport
works- because
webpack-dev-server
in the child directory we can't find it
Another solution without installing the webpack-cli is to set the NODE_PATH, so command
NODE_PATH="$NODE_PATH:/usr/src/app/child-app/node_modules" ./node_modules/.bin/webpack serve --mode development
will serve as expected also.
It is not a workaround, it is a valid solution
from webpack-cli.
Related Issues (20)
- Incorrect warning about watch command HOT 4
- while calling remote app getting [object object] i used webpack when i open separate it's work fine but when open in host app and call remote app getting error [object object] HOT 1
- Import error after updating to v5.1.2 HOT 3
- Accept `undefined` and `null` in `plugins` array HOT 3
- Chore: Update dependencies
- Project HOT 1
- Unable to specify custom config loader in Node 20 (`--loader tsx`) HOT 2
- @webpack-cli/[email protected] has some deprecated NPM modules HOT 3
- debuglog: Package no longer supported. HOT 2
- @npmcli/move-file: This functionality has been moved to @npmcli/fs HOT 1
- `esbuild-kit/tsx` loader support for TypeScript configuration HOT 6
- Cannot read properties of undefined (reading 'getArguments') HOT 13
- Feature request: Include testing of updating dependencies in a readme
- With default config, the webpack serve does not serve the images in html HOT 5
- `--node-env` doesn't set the `mode` as expected HOT 3
- Add support for tsimp TS loader HOT 7
- Cannot Get Rid Of "Module not found: Error: Can't resolve 'fs/promises'" HOT 1
- webpack-cli wants `@swc/register` but it is deprecated for `@swc-node/register` HOT 2
- process.loadEnvFile(); fails to load HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from webpack-cli.