Skip to content
This repository has been archived by the owner on Dec 9, 2023. It is now read-only.

TypeError: Cannot read property 'sitemap' of undefined #10

Closed
somecho opened this issue Mar 12, 2020 · 5 comments
Closed

TypeError: Cannot read property 'sitemap' of undefined #10

somecho opened this issue Mar 12, 2020 · 5 comments
Labels
bug Something isn't working

Comments

@somecho
Copy link

somecho commented Mar 12, 2020

Hello! Running npm run serve produces this error. Full log:

TypeError: Cannot read property 'sitemap' of undefined
    at /home/samuelc/MEGA/webdev/samuel-cho-v3/node_modules/vue-cli-plugin-sitemap/index.js:45:50
    at Service.run (/home/samuelc/MEGA/webdev/samuel-cho-v3/node_modules/@vue/cli-service/lib/Service.js:230:12)
    at Object.<anonymous> (/home/samuelc/MEGA/webdev/samuel-cho-v3/node_modules/@vue/cli-service/bin/vue-cli-service.js:36:9)
    at Module._compile (internal/modules/cjs/loader.js:1151:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1171:10)
    at Module.load (internal/modules/cjs/loader.js:1000:32)
    at Function.Module._load (internal/modules/cjs/loader.js:899:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] sitemap: `vue-cli-service sitemap`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] sitemap 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/samuelc/.npm/_logs/2020-03-12T20_28_22_841Z-debug.log

Here are the contents of the debug log:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'sitemap' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'presitemap', 'sitemap', 'postsitemap' ]
5 info lifecycle [email protected]~presitemap: [email protected]
6 info lifecycle [email protected]~sitemap: [email protected]
7 verbose lifecycle [email protected]~sitemap: unsafe-perm in lifecycle true
8 verbose lifecycle [email protected]~sitemap: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/samuelc/MEGA/webdev/samuel-cho-v3/node_modules/.bin:/home/samuelc/.local/bin:/usr/local/bin:/usr/bin:/bin:/usr/local/sbin:/usr/lib/jvm/default/bin:/usr/bin/site_perl:/usr/bin/vendor_perl:/usr/bin/core_perl
9 verbose lifecycle [email protected]~sitemap: CWD: /home/samuelc/MEGA/webdev/samuel-cho-v3
10 silly lifecycle [email protected]~sitemap: Args: [ '-c', 'vue-cli-service sitemap' ]
11 silly lifecycle [email protected]~sitemap: Returned: code: 1  signal: null
12 info lifecycle [email protected]~sitemap: Failed to exec sitemap script
13 verbose stack Error: [email protected] sitemap: `vue-cli-service sitemap`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:321:20)
13 verbose stack     at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:321:20)
13 verbose stack     at maybeClose (internal/child_process.js:1026:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid [email protected]
15 verbose cwd /home/samuelc/MEGA/webdev/samuel-cho-v3
16 verbose Linux 5.4.22-1-MANJARO
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "sitemap"
18 verbose node v13.9.0
19 verbose npm  v6.13.7
20 error code ELIFECYCLE
21 error errno 1
22 error [email protected] sitemap: `vue-cli-service sitemap`
22 error Exit status 1
23 error Failed at the [email protected] sitemap script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

Any help would be appreciated. Thanks!

@cheap-glitch
Copy link
Owner

Hi,
can you post the contents of your vue.config.js? My guess is that there's no pluginOptions object in it, and the plugin expects one.

I'll push a hotfix, in the meantime you can probably fix the issue by adding the prop pluginOptions to the main config object with an empty object as value.

@somecho
Copy link
Author

somecho commented Mar 13, 2020

Hi, thanks for your super quick response!

This is the vue.config.js :

const routes = require("./routes/routes.js");

module.exports = {
	pluginOptions: {
		sitemap: {
			baseURL: "https://samuel-cho.net",
			routes
		}
	}
};

I've tried using both baseURL and publicPath. I've also tried just using an empty pluginOptions prop.

@cheap-glitch cheap-glitch reopened this Mar 13, 2020
@cheap-glitch
Copy link
Owner

Did you try with the latest version of the plugin (2.1.1)?

@somecho
Copy link
Author

somecho commented Mar 13, 2020

I just saw that and did an update. Now it works, however with a few caveats. It works when used as a standalone plugin, when I hard code the URLs in. But when used with vue router, it throws this error:

TYPE should be array

> 1 | {"baseURL":"https://samuel-cho.net","routes":{},"productionOnly":false,"trailingSlash":false,"pretty":false,"defaults":{},"urls":[]}
    |                                              ^^ 👈🏽  type should be array

If I hard code the array in, it throws this error:

> 1 | {"baseURL":"https://samuel-cho.net","productionOnly":false,"trailingSlash":false,"pretty":false,"defaults":{},"routes":[],"urls":[]}
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 👈🏽  anyOf should match some schema in anyOf

@somecho
Copy link
Author

somecho commented Mar 13, 2020

Sorry, I think it was because I was using ES6 in my routes.js file, doing export default instead of module.exports. The plugin now works perfectly. Thank you for your help!

@cheap-glitch cheap-glitch added the bug Something isn't working label Oct 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants