Angular 2 - Cannot read property 'AssetUrl' of undefined - node.js

I am new at angular2 and material-design. I am trying to use them togeather.
I cloned this material2-app, which is application code based on angular2 and material2 and run npm install.
When I run this command npm start to start a server. I got this error. Any Leads ?
Error-from-terminal
> m2-app#0.0.0 start /home/adil/Code/AngularJS.2/a-simple-app/material2-app
> ng serve
Cannot read property 'AssetUrl' of undefined
TypeError: Cannot read property 'AssetUrl' of undefined
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/#angular/compiler-cli/src/private_import_compiler.js:10:51)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/#angular/compiler-cli/src/reflector_host.js:13:33)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/#angular/compiler-cli/src/path_mapped_reflector_host.js:16:24)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/#angular/compiler-cli/src/codegen.js:16:36)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/#angular/compiler-cli/index.js:12:17)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/#ngtools/webpack/src/plugin.js:6:18)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/#ngtools/webpack/src/index.js:6:10)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/models/webpack-build-typescript.js:5:17)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/models/webpack-config.js:2:34)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/tasks/build-webpack.js:6:24)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/commands/build.js:3:23)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Class.module.exports.includedCommands (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/addon/index.js:21:16)
at /home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/lib/models/project.js:392:61
at Array.forEach (native)
at Project.addonCommands (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/lib/models/project.js:391:15)
at Project.eachAddonCommand (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/lib/models/project.js:426:30)
at module.exports (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/lib/cli/lookup-command.js:33:13)
at CLI.<anonymous> (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/angular-cli/lib/cli/cli.js:34:26)
at tryCatch (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/rsvp/dist/rsvp.js:538:12)
at invokeCallback (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/rsvp/dist/rsvp.js:553:13)
at publish (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/rsvp/dist/rsvp.js:521:7)
at flush (/home/adil/Code/AngularJS.2/a-simple-app/material2-app/node_modules/rsvp/dist/rsvp.js:2373:5)
at nextTickCallbackWith0Args (node.js:419:9)
at process._tickCallback (node.js:348:13)
npm ERR! Linux 4.4.0-45-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "start"
npm ERR! node v4.2.6
npm ERR! npm v3.5.2
npm ERR! code ELIFECYCLE
npm ERR! m2-app#0.0.0 start: `ng serve`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the m2-app#0.0.0 start script 'ng serve'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the m2-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! ng serve
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs m2-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls m2-app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/adil/Code/AngularJS.2/a-simple-app/material2- app/npm-debug.log

I faced similar issue. It seems to problem with new compiler-cli of Angular. I resolved it by adding following in devDependencies in package.json
"#angular/compiler-cli": "^2.0.0"
After doing npm install again error was gone.

you should add ng2material in system.js
as
var map = {
'ng2-material': 'node_modules/ng2-material',
};
var packages = {
'ng2-material': {defaultExtension: 'js'},
};

Related

Shopware 6 development-template installation "frontend open as broken"

I am creating the plugin in Shopware 6.So i have installed "development-template" reference from this question
Shopware 6 Command './psh.phar administration:build.' is not working
After following all the steps for installation when i opened front-end it is broken , where as back-end is working fine.
broken front-end(image)
I have found that "./psh.phar storefront:build" command is not working.It causes node.js error shown as below
/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/build/utils.js:116
} catch {
^
SyntaxError: Unexpected token {
at NativeCompileCache._moduleCompile (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:240:18)
at Module._compile (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:186:36)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/build/webpack.base.config.js:6:15)
at Module._compile (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at Object.<anonymous> (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/webpack.config.js:23:5)
at Module._compile (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
at WEBPACK_OPTIONS (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/utils/convert-argv.js:116:13)
at requireConfig (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/utils/convert-argv.js:118:6)
at /var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/utils/convert-argv.js:125:17
at Array.forEach (<anonymous>)
at module.exports (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/utils/convert-argv.js:123:15)
at yargs.parse (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/cli.js:71:45)
at Object.parse (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/node_modules/yargs/yargs.js:567:18)
at /var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/cli.js:49:8
at Object.<anonymous> (/var/www/html/shopware6/vendor/shopware/platform/src/Storefront/Resources/node_modules/webpack-cli/bin/cli.js:365:3)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sw-next-storefront#1.0.0 production: `NODE_ENV=production webpack --config webpack.config.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sw-next-storefront#1.0.0 production script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/rahul/.npm/_logs/2019-09-24T09_05_58_383Z-debug.log
Execution aborted, a subcommand failed!
i think solving this can fix front-end broken error.
After updating node and npm to latest version, its working now.I think the error was with nodejs.

Error: Cannot find module 'symbol-observable' in Ionic 4

Tried running ng serve this error keep appearing
Error: Cannot find module 'symbol-observable'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.Module._load (internal/modules/cjs/loader.js:562:25)
at Module.require (internal/modules/cjs/loader.js:690:17)
at require (internal/modules/cjs/helpers.js:25:18)
at Object.<anonymous> (C:\Users\USER\AppData\Roaming\npm\node_modules\#angular\cli\lib\init.js:10:1)
at Module._compile (internal/modules/cjs/loader.js:776:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
at Module.load (internal/modules/cjs/loader.js:653:32)
at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
at Function.Module._load (internal/modules/cjs/loader.js:585:3)
using npm
npm install --save symbol-observable
https://github.com/benlesh/symbol-observable
then import it where you using
import Symbol_observable from 'symbol-observable';

webpack Error: custom keyword definition is invalid: data/errors should be boolean

I'm using webpack to bundle two js files(test.js and index.js)
This is how test.js looks like
console.log("i'm in test.js");
export default 35;
This is how index.js looks like
const num = require("./test");
console.log("Successfully export the number: " + num);
This is how my package.json file looks like
"scripts": {
"dev": "webpack"
},
"devDependencies": {
"webpack": "^4.29.3",
"webpack-cli": "^3.2.3"
}
I'm getting this error when I run the command "npm run dev" both of my files are working correctly.
> forkify#1.0.0 dev C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter
> webpack
C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\webpack-cli\bin\cli.js:231
throw err;
^
Error: custom keyword definition is invalid: data/errors should be boolean
at Ajv.addKeyword (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\ajv\lib\keyword.js:65:13)
at module.exports (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\ajv-errors\index.js:10:7)
at Object.<anonymous> (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\schema-utils\src\validateOptions.js:22:1)
at Module._compile (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at Object.<anonymous> (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\schema-utils\src\index.js:7:25)
at Module._compile (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at Object.<anonymous> (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\webpack\lib\SourceMapDevToolPlugin.js:13:25)
at Module._compile (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:159:20)
at Object.<anonymous> (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\webpack\lib\WebpackOptionsApply.js:16:32)
at Module._compile (C:\Users\Seinfeld\Desktop\js\complete-javascript-course-master\9-forkify\starter\node_modules\v8-compile-cache\v8-compile-cache.js:178:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! forkify#1.0.0 dev: `webpack`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the forkify#1.0.0 dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Seinfeld\AppData\Roaming\npm-cache\_logs\2019-02-10T08_30_11_517Z-debug.log````
Anyone who knows the answer please tell me.
Thanks in advance
It's actually bug from webpack itself. You can downgrade to another version.
Here is the Issue
If you use yarn
add below to package.json
"resolutions": {
"ajv": "6.8.1"
}
then run yarn install
if you use npm
npm uninstall ajv
npm install ajv#6.8.1

NodeJS Error: Module version mismatch. Expected 48, got 46

After I upgraded NodeJS and NPM to 6.2.0 and 3.9.3, when I run hexo d -g command to update my blog, I get the following error:
Error: Module version mismatch. Expected 48, got 46.
at Error (native)
at Object.Module._extensions..node (module.js:568:18)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
{ Error: Cannot find module './build/default/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32) code: 'MODULE_NOT_FOUND' }
{ Error: Cannot find module './build/Debug/DTraceProviderBindings'
at Function.Module._resolveFilename (module.js:440:15)
at Function.Module._load (module.js:388:25)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/dtrace-provider/dtrace-provider.js:17:23)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32)
at tryModuleLoad (module.js:417:12)
at Function.Module._load (module.js:409:3)
at Module.require (module.js:468:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/local/lib/node_modules/hexo-cli/node_modules/bunyan/lib/bunyan.js:79:18)
at Module._compile (module.js:541:32)
at Object.Module._extensions..js (module.js:550:10)
at Module.load (module.js:458:32) code: 'MODULE_NOT_FOUND' }
(node) v8::ObjectTemplate::Set() with non-primitive values is deprecated
(node) and will stop working in the next major release.
I thought maybe Node.js is upgraded and node_modules should be reinstalled.
I tried rm -rf node_modules && npm install, but it doesn't work. I also tried sudo npm i -g npm then npm install hexo --no-optional --save, which doesn't work neither.
Any advice would be most appreciated.
Actually, after upgrading node, your installed packages kept compiled against the older version, and they need to be rebuilt. No need to delete node_modules, or running npm update.
Just run:
npm rebuild
Hexo doesn't seem to work with lastest version of node which is 6.2.0. You should use node-v4.4.5 (LTS) for a while, which is recommended version for most users.
It looks like hexo is a globally installed package, but you only reinstalled it locally. Try to reinstall it globally:
npm install hexo -g
Maybe your Global installation files has not been update, please try to update your hexo-cli with command below:
sudo npm install -g hexo-cli
which solved my problem.

Node.js Error: Cannot find module 'libxml-xsd'

I am currently learning node and pulled a git project. When I am trying to run the main javascript file with the command node main.js, it is throwing the below error:
module.js:340
throw err;
^
Error: Cannot find module 'libxml-xsd'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/me/project/controller/product.js:12:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/me/project/main.js:44:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
I tried to run 'npm install libxml-xsd', but was not successful.
When I did npm list it says UNMET DEPENDENCY libxml-xsd#^0.2.0 and below is the stacktrace:
npm ERR! missing: libxml-xsd#^0.2.0, required by me#0.0.0
npm ERR! extraneous: libxmljs#0.15.0 /Users/me/project/node_modules/libxmljs
npm ERR! extraneous: libxmljs-easy#0.2.1 /Users/me/project/node_modules/libxmljs-easy
NOTE: I already ran npm install libxmljs, npm install libxmljs-easy and using Mac OS X 10.11. Node version - v0.10.36 and npm version - 2.14.7
EDIT: Using libxmljs directly also didn't fix the problem (as suggested by one user below)

Resources