wernerglinka / metalsmith-netlify-starter

MIT License
5 stars 1 forks source link

npm start - TypeError: Cannot read properties of undefined (reading 'layout') #2

Open t4rra opened 1 year ago

t4rra commented 1 year ago

Followed the documentation (clone, npm install, npm start) and didn't touch any files, but when I get to the npm start command, it fails.

I'm running Windows 11 and Nodejs 18.12.1 if that helps. Netlify deploys the site just fine, I have not been able to run it locally.

I've pasted the full output below.

PS D:\Code\my-site> npm start

> metalsmith-netlify-cms-starter@0.0.1 start
> cross-env NODE_ENV=development NODE_PATH=./node_modules npm run watch & npm run serve

> metalsmith-netlify-cms-starter@0.0.1 watch
> nodemon metalsmith.js

[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src\**\* templates
[nodemon] watching extensions: js,css,scss,njk,json,html,md
[nodemon] starting `node metalsmith.js`
D:\Code\my-site\node_modules\@metalsmith\layouts\lib\index.cjs:53
  if (file.layout || file.layout === false) {
           ^

TypeError: Cannot read properties of undefined (reading 'layout')
    at getLayout (D:\Code\my-site\node_modules\@metalsmith\layouts\lib\index.cjs:53:12)
    at validate (D:\Code\my-site\node_modules\@metalsmith\layouts\lib\index.cjs:108:18)
    at D:\Code\my-site\node_modules\@metalsmith\layouts\lib\index.cjs:168:56
    at Array.filter (<anonymous>)
    at Ware.layouts (D:\Code\my-site\node_modules\@metalsmith\layouts\lib\index.cjs:168:37)
    at Ware.<anonymous> (D:\Code\my-site\node_modules\wrap-fn\index.js:45:19)
    at Immediate.next (D:\Code\my-site\node_modules\ware\lib\index.js:85:20)
    at Immediate.<anonymous> (D:\Code\my-site\node_modules\wrap-fn\index.js:121:18)
    at process.processImmediate (node:internal/timers:471:21)

Node.js v18.12.1
[nodemon] app crashed - waiting for file changes before starting...
wernerglinka commented 1 year ago

I have not used node 18 yet. I am using 16.17.1 on a Mac. I can't upgrade right now, so you'll have to try to use v16.

wernerglinka commented 1 year ago

I am checking with the Metalsmith maintainer if there are any known issues with node 18. Will let you know

t4rra commented 1 year ago

I've also tried node 16 w/ npm 8.15.0, same error, unfortunately.

wernerglinka commented 1 year ago

This looks like an error by the @metalsmith/layouts plugin. I'll be checking with the Metalsmith maintainer. He is in Europe so I'll not be hearing from him until tomorrow.

wernerglinka commented 1 year ago

There is an issue with the permalink plugin that impacts windows. In metalsmith.js add the following option: .use(permalinks({relative: false})) that should do it. I have also updated the repo.

t4rra commented 1 year ago

Experiencing a different issue now: when running npm start, it skips running npm run serve. Everything works fine on a chromebook running linux, but not on my windows machine. Pasted the output below.

PS D:\Code\metalsmith-netlify-starter> npm start

> metalsmith-netlify-cms-starter@0.0.2 start
> cross-env NODE_ENV=development NODE_PATH=./node_modules npm run watch & npm run serve

> metalsmith-netlify-cms-starter@0.0.2 watch
> nodemon metalsmith.js

[nodemon] 2.0.20
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): src\**\* templates
[nodemon] watching extensions: js,css,scss,njk,json,html,md
[nodemon] starting `node metalsmith.js`
[nodemon] clean exit - waiting for changes before restart