question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Cannot find module package.json

See original GitHub issue

Describe the Bug

I would like to use a custom webpack typescript config with the define plugin but cannot import package.json. Which tsconfig is taken by angular-builders for the webpack config compilation? I tried adding that file to every webpack config without success.

webpack.config.ts:7:22 - error TS2732: Cannot find module './package.json'. Consider using '--resolveJsonModule' to import module with '.json' extension

7 import * as pkg from './package.json'

Minimal Reproduction

  1. Create a start
  2. Include @angular-builders/custom-webpack:browser
  3. Create a webpack.config.ts
  4. Add package.json as a module
  5. Run npm run build

https://github.com/muuvmuuv/angular-builders-issues-816

Expected Behavior

A clear and concise description of what you expected to happen.

Screenshots

If applicable, add screenshots to help explain your problem.

Environment


Libs
- @angular/core version: 10.0.10
- @angular-devkit/build-angular version: 0.1000.6
- @angular-builders/custom-webpack version: 10

For Tooling issues:
- Node version: 12.18.0
- Platform: latest macOS

Others:

Additional Context

Add any other context about the problem here.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:1
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
muuvmuuvcommented, Aug 27, 2020

Just fyi with require the error is gone and it works as expected.

0reactions
muuvmuuvcommented, Sep 2, 2020

For 2. I think you are right. Might be better to hardcode it and later add that it is using the app’s tsconfig.

Read more comments on GitHub >

github_iconTop Results From Across the Web

6 - Stack Overflow
There are a lot, but I can't seem to find a solution for this. I've already deleted node_modules folder and package-lock.json file from...
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
How to Fix the "cannot find module" Error · delete the node modules folder by running rm -rf node_modules · delete package.lock.json file...
Read more >
Error: Cannot find module '/package.json' · Issue #1353 - GitHub
Dashboard app unable to start, displaying error message. After starting the Cube.js development server $ npm run dev Navigate to "Dashboard ...
Read more >
Error: Cannot find module in JavaScript [SOLVED]
We can solve Error: Cannot find module by installing the missing module. We can use npm tool to install the mising module.
Read more >
Cannot find module '<project path>/src/package.json' after run ...
Hello, good day, I've an annoying problem, I wanted to jump to the package.json file but by mistake I click over "package.json file......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found