Assetic: Cannot find module 'less' - less

The problem:
I am using laravel 4 + basset for asset management (OSX).
i have added the twitter bootstrap to my composer as a dependency.
I want to compile the less files into a collection:
Basset::collection('TwitterBootstrap', function($collection)
{
// Collection definition.
$collection->add('../vendor/twbs/bootstrap/less/bootstrap.less');
})->apply('Less');
I then try to build the collection:
php artisan basset:build TwitterBootstrap
Which throws the error:
[Assetic\Exception\FilterException]
An error occurred while running:
'/usr/local/bin/node' '/private/var/folders/f4/xjby77695pbcgfdjfclfdqd40000gn/T/assetic_less5y7dnh'
Error Output:
module.js:340
throw err;
^
Error: Cannot find module 'less'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/private/var/folders/f4/xjby77695pbcgfdjfclfdqd40000gn/T/assetic_less5y7dnh:1:74)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
I have installed less globally - im unsure why this is throwing errors/what to fix (my path? a node config? an assetic config?)

I had the same problem and I solved it by installing less with npm :
npm install less
To use less globally, do not run "npm install less" at the root of your project.
Instead add a symlink to the global one (/home/{user}/node_modules/less/) in your project :
ln -s /home/{user}/node_modules/less/ /path/to/project/node_modules/less
ln -s /home/{user}/node_modules/less/bin/lessc /path/to/project/node_modules/less/.bin/lessc

How did you install less?
npm install less
Reference: https://npmjs.org/package/less
Edit... Just saw your footnote.
Another option would be to install lessPHP via composer and use LessphpFilter instead of LessFilter

Related

Using npm to install puppetteer gives Error: Cannot find module 'puppeteer/internal/node/install.js'

Trying to install puppeteer on Centos 7
npm i puppeteer
> puppeteer#19.4.1 postinstall /mypath/node_modules/puppeteer
> node install.js
internal/modules/cjs/loader.js:775
throw err;
^
Error: Cannot find module 'puppeteer/internal/node/install.js'
Require stack:
- /mypath/node_modules/puppeteer/install.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:772:15)
at Function.Module._load (internal/modules/cjs/loader.js:677:27)
at Module.require (internal/modules/cjs/loader.js:830:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (/mypath/node_modules/puppeteer/install.js:38:27)
at Module._compile (internal/modules/cjs/loader.js:936:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:947:10)
at Module.load (internal/modules/cjs/loader.js:790:32)
at Function.Module._load (internal/modules/cjs/loader.js:703:12)
at Function.Module.runMain (internal/modules/cjs/loader.js:999:10) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/mypath/node_modules/puppeteer/install.js'
]
}
It doesn't seem to have downloaded anything into the node_modules/ directory, which I think "npm i" should do, and all of the tutorials I have read do not ask you perform any action or download, before running the npm command.
What do I need to do, to make this install puppeteer? (with chrome)
I was getting this error because my node version was too old (version 10) but fixed it by switching to version 16.
To fix this I used nvm from the command line as follows:
nvm use 16
nvm alias default 16

Cannot find npm module, after installing apisync-generator with npm

I've run into a wall with using AsyncAPI-Generator on a windows server.
I've been following these instructions and after successfully installing ag I needed to update the path the be able to access the CLI.
When running the cli I get an error saying that ag cannot find the npm module, despite being installed using npm.
C:\Users\jontia\workspace>ag cud.yml #asyncapi/java-spring-template
C:\Users\jontia\.sdkman\candidates\java\20.2.0.r11-grl\languages\js\bin\node_modules\#asyncapi\generator\node_modules\global-npm\index.js:11
var err = new Error("Cannot find module 'npm'")
^
Error: Cannot find module 'npm'
at throwNotFoundError (C:\Users\jontia\.sdkman\candidates\java\20.2.0.r11-grl\languages\js\bin\node_modules\#asyncapi\generator\node_modules\global-npm\index.js:11:13)
at exports (C:\Users\jontia\.sdkman\candidates\java\20.2.0.r11-grl\languages\js\bin\node_modules\#asyncapi\generator\node_modules\global-npm\index.js:39:5)
at Object.<anonymous> (C:\Users\jontia\.sdkman\candidates\java\20.2.0.r11-grl\languages\js\bin\node_modules\#asyncapi\generator\node_modules\global-npm\index.js:27:18)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.<anonymous> (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\jontia\.sdkman\candidates\java\20.2.0.r11-grl\languages\js\bin\node_modules\#asyncapi\generator\node_modules\npmi\npmi.js:1:14) {
code: 'MODULE_NOT_FOUND'
}
This doesn't make any sense to me, how can the npm module not be available when I'm using it?

Vue Cli: Cannot find module '../package.json' error after npm install

I am not an expert in Vuejs or Vuecli, but I do manage to get stuff working.
I had a project i worked on before using Vuecli3 and webpack and now when I opened it after few weeks to make changes, i get the below error in dev mode
$ vue-cli-service serve --open --mode development --dashboard
internal/modules/cjs/loader.js:582
throw err;
^
Error: Cannot find module '../package.json'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:580:15)
at Function.Module._load (internal/modules/cjs/loader.js:506:25)
at Module.require (internal/modules/cjs/loader.js:636:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/Volumes/Drobo/Dropbox/NASDAQ Dubai/Marketdata-6-Indices/node_modules/.bin/vue-cli-service:5:25)
at Module._compile (internal/modules/cjs/loader.js:688:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:699:10)
at Module.load (internal/modules/cjs/loader.js:598:32)
at tryModuleLoad (internal/modules/cjs/loader.js:537:12)
at Function.Module._load (internal/modules/cjs/loader.js:529:3)
Total task duration: 0.15s
The package.json file is right there in the root director and also the .lock file. Dont know what is the reason for this error in compiling.
Any help hightly appreciated
As #vesperknight mentioned in the comment, this issue tends to happen when you move the project's folder to another location.
To solve this (on Linux), from the root directory of your project:
Delete existing node modules.
rm -r node_modules
Reinstall all dependencies:
npm install
The first step seems to be important.

Error: Cannot find module 'wrappy'

When I try to restore my packages via yarn I'm receiving the following error:
npm run yarn --ignore-platform --ignore-optional
...
error C:\Users\mdepouw\source\repos\MyRepo\node_modules\node-sass: Command failed.
Exit code: 1
Command: node scripts/install.js
Arguments:
Directory: C:\Users\mdepouw\source\repos\MyRepo\node_modules\node-sass
Output:
module.js:471
throw err;
^
Error: Cannot find module 'wrappy'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (C:\Users\mdepouw\source\repos\MyRepo\node_modules\inflight\inflight.js:1:76)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
When I a npm install it works fine.
Why does one work but not the other?
This usually happens when you update npm. To resolve this go to path "C:\Users[username]\AppData\Roaming" and delete "npm" and "npm-cache" folders. Then uninstall nodejs and reinstall using updated installer. This should solve your problem.

Error running Gulp in Sylius

I've got a new install of Sylius that I'm working with. I just installed NPM and Gulp, and wanted to run Gulp for the first time. I'm getting an error, and have never worked with Gulp or Sylius before, so it's a little hard for me to understand:
gulp
module.js:328
throw err;
^
Error: Cannot find module 'gulp-if'
at Function.Module._resolveFilename (module.js:326:15)
at Function.Module._load (module.js:277:25)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/var/www/mysite.com/public_html/Gulpfile.js:2:14)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
This is happening on a Ubuntu system, but it also seems to be throwing the same error on my Mac, with a copy of the same Sylius install on it.
try running npm i -S gulp-if in your project. What this does is install the gulp-if package and saves it in your package.json file