diff --git a/compiler/options.nim b/compiler/options.nim
index b4d2bb64e..05bc696e4 100644
--- a/compiler/options.nim
+++ b/compiler/options.nim
@@ -465,7 +465,8 @@ proc setDefaultLibpath*(conf: ConfigRef) =
       else:
         conf.libpath = prefix / RelativeDir"lib"
     else:
-      conf.libpath = prefix / RelativeDir"lib"
+      conf.libpath = prefix / RelativeDir"lib/nim"
+      if not existsDir(conf.libpath.string): conf.libpath = prefix / RelativeDir"lib"
 
     # Special rule to support other tools (nimble) which import the compiler
     # modules and make use of them.
