Search code examples
laravelsassphpstorm

Can not resolve directory "node_modules" in PhpStorm with Laravel Project


PC:Windows 10 V1607.
PhpStorm 2016.3.2
Build #PS-163.10504.2, built on December 20, 2016
JRE: 1.8.0_112-b15 amd64
JVM: Java HotSpot(TM) 64-Bit Server VM by Oracle Corporation

  1. I have already mark "node_modules" as Resource Root in setting.
  2. I have cleaned the IDE (PhpStorm) cache and reindex files.

resources/assets/sass/app.scss which was built with Laravel still get the inspection "can not resolve the directory "node_modules"".

// Bootstrap
@import "node_modules/bootstrap-sass/assets/stylesheets/bootstrap"; // can't resolve the directory by IDE.

Solution

  • Mark project root as Resources Root in File->Settings->Direcotries. If you want to locate the uri in your blade, mark your project/public as Resources Root too. Hope it could help.

    Thanks @patricus

    I have received Phpstorm team's same answer about that, and strong recommend to use Jetbrains' JDK instead of Oracle's.

    So it is necessary to switch to Jetbrains' JDK build instead of Oracle by following these steps:

    1.Go to File | Settings | Plugins > Install JetBrains Plugin
    2.Find and install JB SDK Bintray Downloader plugin
    3.After the restart, press Ctrl+Shift+A or Help > Find Action
    4.Type in "Get JB SDK from BinTray" and press Enter
    5.From the list select the latest JDK build - at this moment it is jbsdk8u112b676_windows_x64.tar.gz (2017-01-13)
    6.Press download, then press Install after it will finish
    7.After a restart check that JVM vendor and JRE version are updated in Help > About screen