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.

Error: Cannot find module '@angular/compiler'?

See original GitHub issue

Bug

[ x] Bug Report
[ ] Feature Request

Description

bug:

I am using an angular4 and “ng-packagr”: “^1.5.0”. if i try to create package it throws following error

node ngoverride.js

module.js:549 throw err; ^

Error: Cannot find module ‘@angular/compiler’ at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at D:\workspace\components\ej2-grid-components\node_modules@angular\compiler-cli\index.js:20:22 at Object.defineProperty.value (D:\workspace\components\ej2-grid-components\node_modules@angular\compiler-cli\index.js:3:17) at Object.<anonymous> (D:\workspace\components\ej2-grid-components\node_modules@angular\compiler-cli\index.js:9:3) at Module._compile (module.js:652:30) at Object.Module._extensions…js (module.js:663:10) at Module.load (module.js:565:32)

If i use angular version 7 and ng-packagr version 4.4.5, it works fine and creating esm15 and fesm15 strucured packages also

My configure file

ngoverride.js

`const ngPackage = require(‘ng-packagr’);

ngPackage .ngPackagr() .forProject(‘ng-package.js’) .withTsConfig(‘tsconfig.lib.json’) .build() .catch(error => { console.error(error); process.exit(1); });`

my ackage.json file

package.json "scripts": { "check": "node ngoverride.js", "packagr": "ng-packagr -p ng-package.json" }

How To Reproduce

Run folloeing commands

npm i

npm run check

error occurs in console

Expected Behaviour

It has to create esm15 and fesm15 structure but it throws error.

if i run like below

creating ng-package.json { "$schema": "./node_modules/ng-packagr/ng-package.schema.json", "lib": { "entryFile": "./public_api.ts" }, "whitelistedNonPeerDependencies": [ "syncfusion", "typedoc", "angular" ] }

package.json ` “scripts”: { “check”: “node ngoverride.js”,

    "packagr": "ng-packagr -p ng-package.json"
}

`

then run following commands, it create package but package does not contain esm15 and fesm15 structures

npm i

npm run packagr

Version Information

working fine and creating esm15 and fesm15 structure

$ node_modules/.bin/ng-packagr --version
ng-packagr: "4.4.5"
@angular/*: "*"
typescript: 3.1.6
node: "8.11.3"
npm/: 5.6.0

not working and do not creating esm15 and fesm15 structure

$ node_modules/.bin/ng-packagr --version
ng-packagr: **less than V1.6.0**
        "@angular/common": "2.2.1 - 4.10.0",
        "@angular/compiler": "^4.4.7",
        "@angular/compiler-cli": "2.2.1 - 4.10.0",
        "@angular/core": "2.2.1 - 4.10.0",
        "@angular/forms": "2.2.1 - 4.10.0",
        "@angular/http": "2.2.1 - 4.10.0",
        "@angular/platform-browser": "2.2.1 - 4.10.0",
        "@angular/platform-browser-dynamic": "2.2.1 - 4.10.0",
        "@angular/platform-server": "2.2.1 - 4.10.0",
        "@angular/router": "2.2.1 - 4.10.0",
        "@schematics/angular": "0.7.2",
typescript: 2.7.2
node: "8.11.3"
npm/: 5.6.0

Please include all version numbers that might be relevant, e.g. third-party libraries

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
JoostKcommented, Dec 21, 2018

FYI: ng-packagr 1 (and Angular 4 for that matter) is no longer supported.

0reactions
github-actions[bot]commented, Jun 19, 2020

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem. This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot find module '@angular/compiler' - Stack Overflow
Does not work for me I am getting this error E:\projects\htdocs\pproject>ng serve An unhandled exception occurred: Cannot find module '@angular/compiler-cli' ...
Read more >
Cannot find module '@angular/compiler-cli' when running ng ...
Error : Cannot find module '@angular/compiler-cli' at Function.Module._resolveFilename (module.js:470:15) at Function.Module.
Read more >
angular/compiler-cli" package was not properly installed
I am unable to get an angular 4 project created with angular cli to compile. I get the ... Error: Error: Cannot find...
Read more >
An unhandled exception occurred: Cannot find module ...
This short blog article shows you how to resolve the Angular error “An unhandled exception occurred: Cannot find module ...
Read more >
@angular/compiler-cli - npm
Start using @angular/compiler-cli in your project by running `npm i @angular/compiler-cli`. ... This package does not have a README.
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