Less file watcher in PhpStorm produces: lessc: ENOENT: no such file or directory - less

I am trying to set up an file watcher for .less files, but it isn't working.
I have globally installed less via npm (npm install -g less). And after this I set up the file watcher according to this documentation from JetBrains supprt. Here is a picture of the settings:
Everytime I will change my .less files, it will produce the following error:
/usr/local/lib/node_modules/less/bin/lessc --no-color styles.less
lessc: ENOENT: no such file or directory, open '/Applications/PhpStorm.app/Contents/bin/styles.less'
Process finished with exit code 1
What went wrong? Any suggestions?
Using the less compiler directly in the project folder via the command line works perfectly (e.g. $ lessc styles.less styles.css)

Using the less compiler directly in the project folder via the command -- line works perfectly (e.g. $ lessc styles.less styles.css)
Try doing the same then -- please try with $FileDir$ in the "Working Directory" field.

Related

What is sproj file?

When running MSBuld prior to setting up my NPM install task, I get an error that the files that NPM would install are missing. The line number of the error is from a file named \sproj. VSCode can not find the file when clicking on it and I don't have a file by that name in my project. What is this file?

Local npm module cannot be found

In a React Boilerplate project, I am trying to use a local module, but getting:
ERROR in ./node_modules/react-sortable-tree-theme-file-explorer/dist/main.js
Module build failed: Error: ENOENT: no such file or directory, open '/Users/username/Documents/project/node_modules/react-sortable-tree-theme-file-explorer/dist/main.js'
Both paths do exist:
$ ls node_modules/react-sortable-tree-theme-file-explorer/dist/main.js
node_modules/react-sortable-tree-theme-file-explorer/dist/main.js
and
$ ls /Users/username/Documents/project/node_modules/react-sortable-tree-theme-file-explorer/dist/main.js
/Users/username/Documents/project/node_modules/react-sortable-tree-theme-file-explorer/dist/main.js
...so I can't figure out what the complaint is. The paths and files DO EXIST. I used npm link initially, but that never worked, and so I also tried npm install ../react-sortable-tree-theme-file-explorer but it gives the exact same results.
I am importing the package as in:
import FileExplorerThemeBase from "react-sortable-tree-theme-file-explorer";

Why can't I run my node packages from the terminal?

Good evening,
I tried installing sails, yo, gulp & bower via the usual methods of npm i -g yo gulp bower etc but each time I open the terminal to run the command I always get the -bash: sails: command not found error.
I listed all my folders at the root of my folder and found the following:
The contents of the .npm-global/bin/ is actually all the packages I'm trying to use at the command line.
I decided to manual add the bin folder to the .bash_profile so it's contents was the following:
# Setting PATH for Python 3.7
# The original version is saved in su
export PATH="/Library/Frameworks/Python.framework/Versions/3.7/bin:${PATH}"
export PATH="/.npm-global/bin:${PATH}"
but that didn't work either.
Here's where I think the problem first arose - I think that the python install overrode all the previous paths in the file (or moved them somewhere perhaps?) so that all previous terminal commands now don't work.
The usual global install for node packages (/usr/local/lib/node_modules/npm/bin) contains the following:
What am I misunderstanding here & how can I fix this?

Watch all sub directories with node-sass

I've seen many examples for watching a specific folder with node-sass, but my css isn't all in the same single folder. I'd like to have it watch all subdirectories for scss files the way you can with onchange (just for example). I'd assume that the syntax would be something like:
`node-sass -w app/**/*.scss -o app/**/`
...but that yields the error: Error: ENOENT: no such file or directory, lstat 'app/**/*.scss'
Is what I'm trying to do even possible with node-sass? If not, is there a better way to mass-compile my scss files to css? I'm trying to stick to just npm scripts for my build if possible.
Try node-sass -rw app -o app.
You might want to change your output folder as this might keep looping.
Source:
-r, --recursive Recursively watch directories or files
https://github.com/sass/node-sass
For node-sass to recognise a newly created file, I found I needed to restart node-sass/npm.

How to npm config save into project .npmrc file?

I am hoping to run npm config to set values in a project's .npmrc file.
Docs dont seem to say how to specify a file to save the values into.
Looking for something like
npm config --file /path/to/repo/.npmrc set key value
Trying to use it for a build script that needs to build a .npmrc file from env vars.
It is baffling that this is seemingly still not directly supported as of npm v6.9.0.
It's a bit awkward, but if your npm version is recent enough, you can repurpose the --userconfig option to make npm config operate on a project-specific .npmrc file.
E.g., from a given project's root folder, the following command project-locally configures pwsh (PowerShell Core) as the shell to run scripts with, by making npm config operate on the local .npmrc file via --userconfig:
# Updates .npmrc in current dir
npm config set script-shell pwsh --userconfig .npmrc
Note: As Kerry Johnson points out:
The target file is rewritten as a whole, in the course of which any comments (#-prefixed lines) in the original file are lost (but all key-value pairs are preserved).
The config keyword is optional in this case, so the following will do:
npm set script-shell pwsh --userconfig .npmrc
You can do a chroot, build your config file on ~/.npmrc and then copy it on the right location.
you can override any property which could be set by the .npmrc
by passing it through command line.
For example --package-lock false will turn off package-lock generation.