Score:0

Installing yo & generator-code on xubuntu

im flag

So I have been trying to install yo & generator-code for xubuntu to try making some vs code extensions, I installed nodejs & npm via sudo apt-get then did sudo npm install -g yo generator-code then when I tried to run yo -v or yo code I get the following error

    filePatterns: lookups.flatMap(prefix => [`${prefix}/*/index.ts`, `${prefix}/*/index.js`, `${prefix}/*/index.cjs`, `${prefix}/*/index.mjs`]),
                          ^

TypeError: lookups.flatMap is not a function
    at Environment.resolver.lookup (/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/resolver.js:70:27)
    at init (/usr/local/lib/node_modules/yo/lib/cli.js:130:7)
    at pre (/usr/local/lib/node_modules/yo/lib/cli.js:89:3)
    at Object.<anonymous> (/usr/local/lib/node_modules/yo/lib/cli.js:219:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

I realized later that sudo wasn't the best approach so I made a new directory for npm-packages and then set the prefix to it

mkdir "/programming/.npm-global"
npm config set prefix "/programming/.npm-global"
gedit ~/.profile

to which I added export PATH=~/programming/.npm-global/bin:$PATH then I did

npm install -g yo generator-code

now when I run yo code I get

/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/resolver.js:70
    filePatterns: lookups.flatMap(prefix => [`${prefix}/*/index.ts`, `${prefix}/*/index.js`, `${prefix}/*/index.cjs`, `${prefix}/*/index.mjs`]),
                          ^

TypeError: lookups.flatMap is not a function
    at Environment.resolver.lookup (/usr/local/lib/node_modules/yo/node_modules/yeoman-environment/lib/resolver.js:70:27)
    at init (/usr/local/lib/node_modules/yo/lib/cli.js:130:7)
    at pre (/usr/local/lib/node_modules/yo/lib/cli.js:89:3)
    at Object.<anonymous> (/usr/local/lib/node_modules/yo/lib/cli.js:219:3)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

and if I run sudo yo code

I get

/usr/local/lib/node_modules/yo/node_modules/conf/index.js:128
            throw err;
            ^

Error: EACCES: permission denied, open '/root/.config/insight-nodejs/insight-yo.json'
    at Object.openSync (fs.js:443:3)
    at Object.readFileSync (fs.js:343:35)
    at Conf.get store [as store] (/usr/local/lib/node_modules/yo/node_modules/conf/index.js:108:18)
    at Conf.get (/usr/local/lib/node_modules/yo/node_modules/conf/index.js:47:27)
    at Insight.get optOut [as optOut] (/usr/local/lib/node_modules/yo/node_modules/insight/lib/index.js:52:22)
    at Object.<anonymous> (/usr/local/lib/node_modules/yo/lib/cli.js:208:48)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:623:3)

Score:0
im flag

So here is how I was able to fix this issue I did the following

npm remove yo

npm remove generator-code

sudo apt remove npm

sudo apt update

sudo apt install build-essential checkinstall libssl-dev

curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.35.1/install.sh | bash

nvm install 16.11.0

npm config delete prefix

npm install -g npm

npm install yo generator-code

yo code
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.