Semantic-UI: Running gulp in project folder, it looks for semantic.json in wrong path
Hi.
Let’s assume we have Semantic-UI installed in C:\projects\node_modules\semantic-ui and we specified during install that our project folder is in C:\projects\brand\web and everything else default.
Then, we navigate to the semantic folder in our project and run gulp build like the installation suggests. It will throw an error like this:
Building Semantic
Cannot build files. Run "gulp install" to set-up Semantic
Trying to figure out the problem, I tried moving the semantic.json to the C:\projects folder, and it worked. So, my guess is that when we run gulp, it looks for its installation path, and then it starts from there, assuming its relative path is the installation path, so it looks for the semantic.json in the wrong place.
The only working solution I found, without moving the semantic.json file out of the project folder, is copying the gulp installation to a node_modules folder inside the project folder.
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 39 (7 by maintainers)
This issue occurs when there is a
node_modulesfolder upstream in the directory tree during installation.For example, if you’re trying to
npm install semantic-ui --saveinC:\Users\ApertureScience\Desktop\SemanticUITestbut happen to have an existingnode_modulesfolder underC:\Users\ApertureScience, then the install wizard will first ask……and then if you say no and specify the absolute path
C:\Users\ApertureScience\Desktop\SemanticUITestinstead, the installer will install Semantic UI in that folder, but will not create anode_modulesthere.If you then try
gulp buildinC:\Users\ApertureScience\Desktop\SemanticUITest\semantic, you get the above error.Hope this helps, @jlukic.
Hi, since Gulp v3.8.1 there’s
process.env.INIT_CWDwhich is the original cwd [the CLI] was launched from.@gaborluk during the
npm install semantic-uithis won’t help, and you’ll need to specify your project path manually, BUT when runninggulp build, whileprocess.cwdisC:\Users\ApertureScience\node_modules,process.env.INIT_CWDis set to the path you rangulp buildfrom. In your case that would beC:\Users\ApertureScience\Desktop\SemanticUITest\semantic.So now the question for @jlukic is where to put this… Options:
requireDotFile('semantic.json')would need as second argumentprocess.env.INIT_CWDprocess.env.INIT_CWDinstead ofpath.join(__dirname, path.sep , '..'), which is a breaking change.INIT_CWDas fallback?I agree, I wish there was an easier way. This was 2 years ago, so my memory is a bit fuzzy on it. I think
userConfig = requireDotFile('semantic.json', __dirname);does fix it. I created a postinstall command though and the extra file, so that everyone on the team doesn’t need to remember to do it when they pull down the project for the first time. Also, if your project is going to run on a build server, this will ensure that change happens there as well. All the best.Faced the same problem. I was able to solve this problem by moving
semantic.jsonfile into my global/usr/lib/node_modulesfolder and that worked!