You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Failed to import module from component node_modules #4134
ERROR in ./src/app/my-component/my-component.component.ts
Module not found: Error: Can't resolve 'lodash.chunk' in '/Users/myuser/Documents/my-project/src/app/my-component'
Mention any other details that might be useful.
I can fix the module resolve in the webpack config, by changing line 39 of webpack-build-common.ts to just use node_modules and let it resolve:
// const nodeModules = path.resolve(projectRoot, 'node_modules');constnodeModules='node_modules';// this works
The reason I need nested node_modules is because we are developing components in a single repo, but we want to separate them out in our deployment build so each component can have its own dependencies.
Is there something I'm missing to make this work out of the box?
@catull, but that is adding the dependency at the app level. I want the component to have its own package.json and dependencies. Like I said, in the build process I need to separate each component so we can publish them independently to our own private npm repository.
We don't really support multiple projects/apps at the moment.
I understand that your usecase could be fixed by adding a local set of node_modules, but that would also remove the fix for npm linked node modules (#2291).
If there's a way to have both working, let me know.
// node_modules/angular-cli/models/webpack-build-common.js @ 27+// var nodeModules = path.resolve(projectRoot, 'node_modules');+varnodeModules='node_modules';// this works
Now both ng serve and ng build work fine, no errors, and I can see both logs in the console during dev, and in the build. Without the fix above it fails.
Am I missing something or do linked packages work just fine without #2291? Maybe webpack fixed it since September?
angular-automatic-lock-bot commented on Sep 6, 2019
Activity
catull commentedon Jan 23, 2017
@elclanrs
There is a simpler way, that works.
Follow these steps:
ng generate component my-componentnpm install --save lodash.chunkThis is not an issue, it can be closed.
elclanrs commentedon Jan 23, 2017
@catull, but that is adding the dependency at the app level. I want the component to have its own package.json and dependencies. Like I said, in the build process I need to separate each component so we can publish them independently to our own private npm repository.
filipesilva commentedon Jan 24, 2017
We don't really support multiple projects/apps at the moment.
I understand that your usecase could be fixed by adding a local set of node_modules, but that would also remove the fix for npm linked node modules (#2291).
If there's a way to have both working, let me know.
elclanrs commentedon Jan 24, 2017
@filipesilva, linked packages seem to work. Just did the following to reproduce:
Using angular-cli@1.0.0-beta.26, create new app, a component, and install sub-dependency:
Create test package and link it to app:
Require both packages in my-component:
Add component to app template:
Edit webpack's config:
Now both
ng serveandng buildwork fine, no errors, and I can see both logs in the console during dev, and in the build. Without the fix above it fails.Am I missing something or do linked packages work just fine without #2291? Maybe webpack fixed it since September?
angular-automatic-lock-bot commentedon Sep 6, 2019
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
This action has been performed automatically by a bot.