Error getting started with LESS
logankilpatrick opened this issue · 1 comments
logankilpatrick commented
I am following the example right from the docs, I include less in my HTML head tag:
<link href="style.css" rel="stylesheet">
<link rel="stylesheet/less" type="text/css" href="custom.less" />
<script src="https://cdn.jsdelivr.net/npm/less@4" ></script>
and then define a file, custom.less
with the following:
@width: 10px;
@height: @width + 10px;
@color: #900;
#header {
width: @width;
height: @height;
}
as per the example from the docs. But I get no content rendering on my page anymore, it stops working: \
[Error] Cross origin requests are only supported for HTTP.
doXHR (less@4:10:136005)
(anonymous function) (less@4:10:136665)
Promise
loadFile (less@4:10:136447)
d (less@4:10:143278)
m (less@4:10:143886)
(anonymous function) (less@4:10:144955)
Promise
(anonymous function) (less@4:10:144738)
(anonymous function) (less@4:10:145916)
(anonymous function) (less@4:10:197)
Global Code (less@4:10:200)
[Error] XMLHttpRequest cannot load file:///Users/logankilpatrick/Desktop/DGMD-E20/Assignment%202/custom.less due to access control checks.
doXHR (less@4:10:136005)
(anonymous function) (less@4:10:136665)
Promise
loadFile (less@4:10:136447)
d (less@4:10:143278)
m (less@4:10:143886)
(anonymous function) (less@4:10:144955)
Promise
(anonymous function) (less@4:10:144738)
(anonymous function) (less@4:10:145916)
(anonymous function) (less@4:10:197)
Global Code (less@4:10:200)
[Error] Unhandled Promise Rejection: TypeError: undefined is not an object (evaluating 'p.href')
(anonymous function) (less@4:10:145006)
(anonymous function) (less@4:10:143826)
promiseReactionJob
[Error] Failed to load resource: the server responded with a status of 404 () (less.min.js.map, line 0)
Any suggestions to resolve this?
iChenLei commented
@logankilpatrick You open the .html
as file by browser directly ? Please use server to hosting your html file. If you develop you project at local machine. you can use follow solutions to create a simple server.
## python2
python -m SimpleHTTPServer
## python3
python3 -m http.server
## PHP
php -S localhost:8000