Hello everyone:
I'm trying to migrate a website to gatsby. I'm using the default starter, i.e. gatsby new blablaproject. After I have the starter I'm trying to install the less plugin, i.e. npm i --save gatsby-plugin-less. After this, I add gatsby-plugin-less to the plugins array in the config file.
It is supposed to work for less files at this point, right? Is there anything else I'm supposed to do?
If I test it by simply changing the index.css to index.less within the layouts directory and also change the reference to it within index.js, it won't work. I've also tried restarting gatsby develop to no avail.
The error I'm getting is:
./src/layouts/index.js
Module not found: Error: Cannot resolve module 'less' in C:\Users....blablabla
This error is in the browser and is displayed by gatsby develop that is running. The terminal running gatsby develop is saying:
WAIT Compiling... 21:14:24
ERROR Failed to compile with 1 errors 21:14:24
This relative module was not found:
After starting and restarting gatsby develop, the browser screen will be blank (rather than showing the error it showed before) but the error in the console is saying it can't find common.js.
Yeah, so has this happened to anyone else or just me? I'm thinking it should be an easy fix but can't figure it out. Having the same exact problem with gatsby-plugin-sass even if I follow the LevelUp Tuts tutorial for adding plugins on youtube.
Any help will be greatly appreciated. Thanks in advance!
It sounds like you're doing the right thing there. That you're getting the same issue with the Sass and Less plugins sounds unusual though. You could try using a starter that uses Sass, then swap the Sass out to Less?
Hopefully that can narrow down the problem a little.
Thank you for the reply.
I've tried to use multiple sass starters. None of them work for basically the same issue. When I change the css file to scss (and the reference) it breaks down and i get an error along the lines of it not being able to read/do anything with (not sure which). Any more ideas I could look into? Is there anything else I need to install? Any environment type issues? Do these plugins work on windows?
Thanks.
Bump.
Tried reinstalling it to no avail. Does anyone get the following errors/warnings when using npm to install gatsby-plugin-less?
$ npm i --save gatsby-plugin-less
npm WARN [email protected] requires a peer of webpack@^2.0.0 || ^3.0.0 || ^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] No repository field.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm audit fix to fix them, or npm audit for detailsI ran into a similar error with Error: Cannot find module 'less' during my upgrade to Gatsby >2.0. I noticed 'less' was listed as a peerdepdency in the new version of gatsby-plugin-less .
Running this resolved the issue for me:
npm i less
This was also added to the readme
@nickrazes -- are you able to reproduce this issue?
Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!
This issue is being closed due to inactivity. Is this a mistake? Please re-open this issue or create a new issue.
Most helpful comment
I ran into a similar error with
Error: Cannot find module 'less'during my upgrade to Gatsby >2.0. I noticed 'less' was listed as a peerdepdency in the new version ofgatsby-plugin-less.Running this resolved the issue for me:
This was also added to the readme