Cannot find npm module, after installing apisync-generator with npm - 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?

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

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

npm module error on 'inflight' when attempting to build semantic UI

I'm attempting to use the React Starter Kit with SemanticUI on Windows. I can install and build RSK, but when I run npm install semantic-ui and go through the set up, I always hit the same module error and I am unsure how to solve it.
gulp build
module.js:341
throw err;
^
Error: Cannot find module 'inflight'
at Function.Module._resolveFilename (module.js:339:15)
at Function.Module._load (module.js:290:25)
at Module.require (module.js:367:17)
at require (internal/module.js:16:19)
at Object.<anonymous> (C:\Users\Alex\AppData\Roaming\npm\node_modules\gulp\node_modules\glob\glob.js:57:16)
at Module._compile (module.js:413:34)
at Object.Module._extensions..js (module.js:422:10)
at Module.load (module.js:357:32)
at Function.Module._load (module.js:314:12)
at Module.require (module.js:367:17)
I have tried nuking the directory and reinstalling multiple times, but I am unable to get this to work. What is causing the issue?
You may be hitting the same issues people are having on npm 2701. The issue appears to be related to version updates between installing NPM modules (from a quick read over the later parts of the report). Suggestions include running:
npm set registry https://registry.npmjs.org/
And alternatively, removing all currently installed node modules including globally installed modules (in /usr/node-modules/ or C:\Program Files\nodejs\node_modules for example). The user deleted them manually (i.e. not using npm).
I also faced same issue while running react app. I simply installed it
npm install inflight
Although after it there prompt another error msg which was failed to find moudule 'source-list-map' then I installed it as well
npm install source-list-map
I hope it will help you

Assetic: Cannot find module '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