NGCC failed error in Angular 11.x app when running npm run - node.js

I have an Angular 11.x app that I run using npm run start - this has worked fine for months but all of a sudden it is no longer running the command and I am getting the following errors, can anyone suggest how I fix this? I have tried the obvious ideas of deleting node_modules and reinstalling them using npm install but with no joy.
Below is the error I get after running npm run start - what have I done to break this :(
Compiling #angular/core : es2015 as esm2015
Error: Error on worker #1: TypeError: Cannot read property 'map' of undefined
at injectDependencies (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler/bundles/compiler.umd.js:6960:21)
at compileFactoryFunction (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler/bundles/compiler.umd.js:6888:61)
at Object.compileInjector (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler/bundles/compiler.umd.js:8106:22)
at NgModuleDecoratorHandler.compileFull (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/src/ngtsc/annotations/src/ng_module.js:427:44)
at _loop_2 (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/src/ngtsc/transform/src/compilation.js:595:39)
at NgccTraitCompiler.TraitCompiler.compile (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/src/ngtsc/transform/src/compilation.js:626:21)
at DecorationAnalyzer.compileFile (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/analysis/decoration_analyzer.js:225:53)
at DecorationAnalyzer.analyzeProgram (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/analysis/decoration_analyzer.js:164:45)
at Transformer.analyzeProgram (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/packages/transformer.js:135:57)
at Transformer.transform (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/packages/transformer.js:77:27)
at ClusterMaster.onWorkerMessage (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/execution/cluster/master.js:195:27)
at /Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/execution/cluster/master.js:55:95
at ClusterMaster.<anonymous> (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/execution/cluster/master.js:293:57)
at step (/Users/zabius/Sites/abc-ui-ng4/node_modules/tslib/tslib.js:143:27)
at Object.next (/Users/zabius/Sites/abc-ui-ng4/node_modules/tslib/tslib.js:124:57)
at /Users/zabius/Sites/abc-ui-ng4/node_modules/tslib/tslib.js:117:75
at new Promise (<anonymous>)
at Object.__awaiter (/Users/zabius/Sites/abc-ui-ng4/node_modules/tslib/tslib.js:113:16)
at EventEmitter.<anonymous> (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular/compiler-cli/ngcc/src/execution/cluster/master.js:287:32)
at EventEmitter.emit (events.js:315:20)
An unhandled exception occurred: NGCC failed.
See "/private/var/folders/b2/1zfdxz293d944p_lxk9_ypz40000gn/T/ng-XQcM3b/angular-errors.log" for further details.
The error in the angular-errors.log file is as follows -
[error] Error: NGCC failed.
at NgccProcessor.process (/Users/zabius/Sites/abc-ui-ng4/node_modules/#ngtools/webpack/src/ngcc_processor.js:129:19)
at /Users/zabius/Sites/abc-ui-ng4/node_modules/#ngtools/webpack/src/angular_compiler_plugin.js:593:31
at SyncHook.eval [as call] (eval at create (/Users/zabius/Sites/abc-ui-ng4/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:19:10$
at SyncHook.lazyCompileHook (/Users/zabius/Sites/abc-ui-ng4/node_modules/webpack/node_modules/tapable/lib/Hook.js:154:20)
at Object.webpack [as webpackFactory] (/Users/zabius/Sites/abc-ui-ng4/node_modules/webpack/lib/webpack.js:55:30)
at createWebpack (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular-devkit/build-webpack/src/webpack-dev-server/index.js:21:36)
at Object.runWebpackDevServer (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular-devkit/build-webpack/src/webpack-dev-server/index.js:47:12)
at SwitchMapSubscriber.project (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular-devkit/build-angular/src/dev-server/index.js:209:32)
at SwitchMapSubscriber._next (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular-devkit/build-angular/node_modules/rxjs/internal/operators/swit$
at SwitchMapSubscriber.Subscriber.next (/Users/zabius/Sites/abc-ui-ng4/node_modules/#angular-devkit/build-angular/node_modules/rxjs/internal/Subs$
at /Users/zabius/Sites/abc-ui-ng4/node_modules/#angular-devkit/build-angular/node_modules/rxjs/internal/util/subscribeToPromise.js:7:24
at processTicksAndRejections (internal/process/task_queues.js:93:5)
Versions :
npm -v 8.1.0
node -v 14.15.4
Using MacOS BigSur 11.5.2

Related

NPM - Failed to replace env in config: ${NPM_BASE64_USERNAME_PASSWORD}

I'm getting the error below whenever I try to execute anything in my terminal (e.g. npm test or npm install)
I've tried to follow steps similar laid out here - NPM - Failed to replace env in config: ${NPM_TOKEN}. I've also tried setting my username and (encoded) password in my .npmrc file, none of which appear to work for me.
Not really sure what else I should try here ....
Error: Failed to replace env in config: ${NPM_BASE64_USERNAME_PASSWORD}
at /Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:415:13
at String.replace (<anonymous>)
at envReplace (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:411:12)
at parseField (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:389:7)
at /Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:330:24
at Array.forEach (<anonymous>)
at Conf.add (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:328:23)
at ConfigChain.addString (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/node_modules/config-chain/index.js:244:8)
at Conf.<anonymous> (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/config/core.js:316:10)
at /Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/node_modules/graceful-fs/graceful-fs.js:123:16
/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/npm.js:59
throw new Error('npm.load() required')
^
Error: npm.load() required
at Object.get (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/npm.js:59:13)
at process.errorHandler (/Users/andrew.lee/.nvm/versions/node/v14.17.1/lib/node_modules/npm/lib/utils/error-handler.js:208:32)
at process.emit (events.js:375:28)
at process._fatalException (internal/process/execution.js:163:25)
Even, I had encounter the issue similar to thiis while pulling the node component from aws codeartifact via docker file. What you need to do is create a .nmprc file and drop it root location fo the npm installaiton, doing this your issue will get addressed. I was getting below exception while ruinnig npm install in docker file something like
Run powershell -command npm install or any anglar cli install via npm
"8 : RUN powershell -Command npm install
2022-03-03T19:16:34.2653417Z ---> Running in 97791ba93799
2022-03-03T19:16:44.2652033Z [91mError: Failed to replace env in config: ${env:CODEARTIFACT_AUTH_TOKEN}
2022-03-03T19:16:44.2652033Z at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:415:13
2022-03-03T19:16:44.2661894Z at String.replace ()
2022-03-03T19:16:44.2661894Z at envReplace (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:411:12)
2022-03-03T19:16:44.2661894Z at parseField (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:389:7)
2022-03-03T19:16:44.2661894Z at C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:330:24
2022-03-03T19:16:44.2661894Z at Array.forEach ()
2022-03-03T19:16:44.2661894Z at Conf.add (C:\Program Files\nodejs\node_modules\npm\lib\config\core.js:328:23)"
Solution
please use this docker file, I was passing token from build file something like
Build.ps1
$env:CODEARTIFACT_AUTH_TOKEN = aws codeartifact get-authorization-token --domain se2codepkg --domain-owner 590427636078 --query authorizationToken --output text
docker.ps1
Run powershell echo "registry=https://se2codepkg-590427636078.d.codeartifact.us-east-1.amazonaws.com/npm/npm-store/
//se2codepkg-590427636078.d.codeartifact.us-east-1.amazonaws.com/npm/npm-store/:always-auth=true
//se2codepkg-590427636078.d.codeartifact.us-east-1.amazonaws.com/npm/npm-store/:_authToken=${env:CODEARTIFACT_AUTH_TOKEN}">.npmrc
I got the idea by going through below link
https://developpaper.com/question/after-nodejs-is-installed-successfully-npm-cannot-run-and-prompt-failed-to-replace-env-in-config/

How do devs maintain old projects?

A year ago I've made a project for a course: https://github.com/GeorgeFlorian/Finished_link_project
Now, I am trying to make it work on my machine, but I have no luck.
I've got npm 7.13.0 and node 16.1.0.
I've ran npm update in order to update all the depencies.
Steps
I've cloned the repo into a PC than runs Linux Mint 20.1
I've ran npm install
npm update
npm run build and npm run serve return the same error:
georgeflorian#georgeflorian-desktop:~/New Volume/VSCode Projects/Finished_link_project$ npm run build
> proiect-link#0.1.0 build
> vue-cli-service build
таз Building for production...
ERROR Failed to compile with 1 error 2:55:41 PM
Syntax Error: TypeError: Cannot read property 'parseComponent' of undefined
You may use special comments to disable some warnings.
Use // eslint-disable-next-line to ignore the next line.
Use /* eslint-disable */ to ignore all warnings in a file.
ERROR Build failed with errors.
I have no idea how to trace the error: Syntax Error: TypeError: Cannot read property 'parseComponent' of undefined.
Also, the NodeJS server won't start:
georgeflorian#georgeflorian-desktop:~/New Volume/VSCode Projects/Finished_link_project/server$ node app.js
node:internal/fs/utils:343
throw err;
^
Error: ENOENT: no such file or directory, stat '/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/dist/favicon.ico'
at Object.statSync (node:fs:1527:3)
at resolveSync (/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/node_modules/serve-favicon/index.js:187:17)
at favicon (/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/node_modules/serve-favicon/index.js:61:12)
at Object.<anonymous> (/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/server/app.js:46:9)
at Module._compile (node:internal/modules/cjs/loader:1109:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1138:10)
at Module.load (node:internal/modules/cjs/loader:989:32)
at Function.Module._load (node:internal/modules/cjs/loader:829:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47 {
errno: -2,
syscall: 'stat',
code: 'ENOENT',
path: '/home/georgeflorian/New Volume/VSCode Projects/Finished_link_project/dist/favicon.ico'
}
I believe that many dependencies are deprecated, but this begs two questions:
If it worked back then and it hasn't been touched since, why doesn't it work now ?
How can I fix all the deprecated dependencies if npm update did not fix them ?
Ultimately, I would like to learn how to approach this kind of situation. Thank you.

Angular zone.js and shim.min.js error

I have downloaded the angular quick start code and set it up in my machine but when i run the command npm start it gives me the following errors:
Uncaught Error: Zone already loaded.
at zone.js:32
at zone.js:643
at FUNCTION (zone.js:11)
at zone.js:12
Unhandled promise rejection TypeError: Zone.assertZonePatched is not a function
at new NgZone (core.umd.js:3807)
at PlatformRef_._bootstrapModuleFactoryWithZone (core.umd.js:4524)
at eval (core.umd.js:4569)
at shim.min.js:8
at shim.min.js:8
at MutationObserver.s (shim.min.js:7)
at Zone.run (angular2-polyfills.js:138)
at MutationObserver.zoneBoundFn (angular2-polyfills.js:111)
I am using node version 6.11.3 and npm version as 3.10.10. So can anybody help me on this?

error: A hook (`userconfig`) failed to load

after npm install , getting error like, i have checked every config file and also installed lodash manually after but still not working
error: A hook (`userconfig`) failed to load!
error: Error: In Sails v1.x, `sails.config.globals._` must be either `false` or an object (typically the value of `require('lodash')`)
at Sails.exposeGlobals (D:\Node_Project\POS\trunk\node_modules\sails\lib\app\private\exposeGlobals.js:47:44)
at Sails.wrapper [as exposeGlobals] (D:\Node_Project\POS\trunk\node_modules\#sailshq\lodash\lib\index.js:3250:19)
at emitNone (events.js:91:20)
at Sails.emit (events.js:185:7)
at Sails.emitter.emit (D:\Node_Project\POS\trunk\node_modules\sails\lib\app\private\after.js:50:11)
at D:\Node_Project\POS\trunk\node_modules\sails\lib\app\private\loadHooks.js:111:15
at Hook.initialize (D:\Node_Project\POS\trunk\node_modules\sails\lib\hooks\index.js:154:14)
at Hook.wrapper [as initialize] (D:\Node_Project\POS\trunk\node_modules\#sailshq\lodash\lib\index.js:3250:19)
at D:\Node_Project\POS\trunk\node_modules\sails\lib\hooks\index.js:88:16
at D:\Node_Project\POS\trunk\node_modules\sails\node_modules\async\dist\async.js:486:20
First : Make sure you've installed dependencies with npm install
Second : Check that this app was built for a compatible version of Sails.

webpack --progress Error: write EINVAL

I'm on Windows 10 recently upgraded my node.js to version 7.1.0. I started to get the following error every time I ran the webpack command with --progress flag.
$ webpack --progress
Node Environment: development events.js:160
throw er; // Unhandled 'error' event
^
Error: write EINVAL
at exports._errnoException (util.js:1022:11)
at WriteStream.Socket._writeGeneric (net.js:715:26)
at WriteStream.Socket._write (net.js:734:8)
at doWrite (_stream_writable.js:334:12)
at writeOrBuffer (_stream_writable.js:320:5)
at WriteStream.Writable.write (_stream_writable.js:247:11)
at WriteStream.Socket.write (net.js:661:40)
at E:\Projects\wad\node_modules\webpack\bin\convert-argv.js:421:20
at Compiler.<anonymous> (E:\Projects\wad\node_modules\webpack\lib\ProgressPlugin.js:77:4)
at Compiler.applyPlugins (E:\Projects\wad\node_modules\tapable\lib\Tapable.js:26:37)
at Compiler.<anonymous> (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:193:12)
at Compiler.emitRecords (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:282:37)
at Compiler.<anonymous> (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:187:11)
at E:\Projects\wad\node_modules\webpack\lib\Compiler.js:275:11
at Compiler.applyPluginsAsync (E:\Projects\wad\node_modules\tapable\lib\Tapable.js:60:69)
at Compiler.afterEmit (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:272:8)
at Compiler.<anonymous> (E:\Projects\wad\node_modules\webpack\lib\Compiler.js:267:14)
at E:\Projects\wad\node_modules\async\lib\async.js:52:16
at done (E:\Projects\wad\node_modules\async\lib\async.js:246:17)
at E:\Projects\wad\node_modules\async\lib\async.js:44:16
at E:\Projects\wad\node_modules\graceful-fs\graceful-fs.js:43:10
at FSReqWrap.oncomplete (fs.js:111:15)
It works fine without the --progress flag and webpack --progress was working fine on node.js v6.x.x. Using webpack --progress with node v.7.1.0 on the same project but another windows 10 machine also works fine.
What does this error mean?
This is a problem of the version node, use the version 6.9 and success
I had the same problem, and i uninstall node7.1, reboot and install node6.9 and all ok
It seems there a bug at node js v7.1.0 nodejs/node#9542. Update to the latest version v7.3.0 and everything will be ok.

Resources