yo #microsoft/sharepoint fails on TypeError: lookups.flatMap is not a function - yeoman

After installation of Node v10.16.1 and installation of gulp and yo (Everything looks alright !) it fails on command yo #microsoft/sharepoint with TypeError: lookups.flatMap is not a function
C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\resolver.js:70
filePatterns: lookups.flatMap(prefix => [`${prefix}/*/index.ts`, `${prefix}/*/index.js`]),
^
TypeError: lookups.flatMap is not a function
at Environment.resolver.lookup (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\node_modules\yeoman-environment\lib\resolver.js:70:27)
at init (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\lib\cli.js:130:7)
at pre (C:\Users\MYNAME\AppData\Roaming\npm\node_modules\yo\lib\cli.js:89:3)
at Object.<anonymous> (C:\Users\MYNAME\AppData\Roaming\npm\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)
I am a beginner ! Few days ago it worked , then I installed nvm (following a microsoft instruction to swap node v8 to node v10) and then problems started and i uninstalled nvm, node v8 and v10 en reinstalled node v10. The TypeError returns. Perhaps something to do with path ?
Any idea ? thx

I resolved this by downgrading my gulp and yeoman versions.
First checked to see what I had installed:
npm list -g --depth=0
Output:
+-- #microsoft/generator-sharepoint#1.11.0
+-- gulp#4.0.2
+-- npm#6.14.12
+-- windows-build-tools#5.2.2
-- yo#4.0.0
So I uninstalled both gulp and yeoman:
npm uninstall -g gulp
npm uninstall -g yo
Then installed older versions:
npm install -g gulp#3.9.1
npm install -g yo#3.1.0
Then was able to generate the SharePoint framework project successfully after running:
yo #microsoft/sharepoint
Once it completed, I was able to run the following from inside the SharePoint framework project directory to launch the local workbench:
gulp serve
Note: If if not already done so once, you need to generate a development certificate inside the SharePoint framework project directory:
gulp trust-dev-cert

I believe you should upgrade node.js to v14, as stated in Microsoft official guide:
Install the latest version of Node.js LTS v14.
This version is the currently recommended version of Node.js to use with the SharePoint Framework
Node v10 is EOL in few days (tomorrow, in fact), so it is unsafe to use it.
I faced the same issue today while scaffolding a new webpart, and I solved by upgrading node from v10 to v14.
Another suggestion is to avoid installing global npm packages if you are going to use it just once (for scaffolding, for example); I usually use npx to download on the fly yo and the microsoft generator, so I always use the latest available versions:
$ npx -p yo -p #microsoft/generator-sharepoint -c "yo #microsoft/sharepoint"
Hope this can help, bye!

First try to uninstall both gulp and yeoman:
to uninstall run these commands-->
npm uninstall -g gulp
npm uninstall -g yo
Then installed older versions:
to install run these commands-->
npm install -g gulp#3.9.1
npm install -g yo#3.1.0
Then was able to generate the SharePoint framework project successfully after running:
yo #microsoft/sharepoint

Check version list if same or not:
npm list -g --depth=0
+-- #microsoft/generator-sharepoint#1.11.0
+-- gulp#3.9.1
+-- gulp-cli#2.3.0
+-- yarn#1.22.17
+-- yo#3.1.0
Run below commands to uninstall:
npm uninstall -g gulp
npm uninstall -g yo
Run below commands:
npm install -g gulp#3.9.1
npm install -g yo#3.1.0
npm uninstall -g #microsoft/generator-sharepoint
Then install a previous version:
npm install -g #microsoft/generator-sharepoint#1.11.0

Related

Yarn Unknown Syntax Error: Unsupported option name ("--check-files")

When I try to run yarn install --check-files on a rails repo that I cloned I'm getting the following error:
Unknown Syntax Error: Unsupported option name ("--check-files").
$ yarn install [--json] [--immutable] [--immutable-cache] [--check-cache] [--inline-builds] [--mode #0]
I've tried updating yarn and node to the latest stable versions
I've tried deleting yarn/node modules and yarn.lock in the local folder and running yarn install again
I've tried yarn upgrade --latest which also brings up a similar error Usage Error: Couldn't find a script named "upgrade".
I'm currently using volta to manage my versions and have not had too much trouble up until now.
I've previously run --check-files on other repos with no problems.
Ok turns out my system was running yarn 3.* globally which was conflicting with my rails version (6.0.5). I had originally installed yarn using brew so I had to uninstall and start again with npm using the following steps:
brew uninstall yarn to remove yarn with brew
npm install -g yarn to install yarn with npm
yarn set version classic to set yarn version to 1.*
yarn -v to make sure I was on version 1.*

Yarn packages won't update for dependency issue

On a development server, for an application barely deployed, rails commands won't execute because of lack of integrity file.
error Couldn't find an integrity file
error Found 1 errors.
========================================
Your Yarn packages are out of date!
Please run `yarn install --check-files` to update.
========================================
Both
yarn install --check-files
yarn install
lead to the same error
compression-webpack-plugin#4.0.1: The engine "node" is incompatible with this module. Expected version ">= 10.13.0". Got "8.17.0"
Found incompatible module
Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
The 'visit' prompt is unfortunately of no use, as it does not deal with the node engine.
Being barely deployed, there is no node-modules directory yet, which is expected. However on development machine there is the directory and no issues whatseoever in precompiling assets.
Server context:
node -v
> v8.17.0
How can this situation be unblocked?
you need to update the node to a version higher than the one mentioned >= 10.13.0 then re-install yarn and re-run the check:
if you're on Mac OS:
brew install node#14 && brew link --force node#14
brew install yarn
if you're on Linux:
cd ~
curl -sL https://deb.nodesource.com/setup_14.x -o nodesource_setup.sh
sudo bash nodesource_setup.sh
sudo apt install nodejs
then check if you have a compatible version
node -v
=> v14.2.0
``
if so re-run any of your commands:
```bash
yarn install --check-files
yarn install

Webpacker Error on creating new rails app in rails 6

When i am creating new rails application i am getting error with webpacker (ArgumentError: Malformed version number string 0.32+git)
I was running into a similar issue running rails 6 on my Docker container. Turns out Rails 6 uses Webpacker, which needs yarn to be installed. Follow steps to install a newer version of Yarn
For Debian make sure these steps are followed
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
and then
sudo apt update && sudo apt install yarn
This gave me yarn --version -> 1.19.1
after which sample rails new blog ran successfully, and added blog/config/webpacker.yml (Related to Vanilla Rails 6.0: "error Command "webpack" not found")
It is strange that the documentation does not mention yarn as a dependency.
I confronted the same issue and resolved by installing yarn using nvm.
npm install -g yarn
After installing and updating yarn to the current version, I have my Webpacker successfully installed.
I installed yarn by running sudo apt-get installed yarn on my POP OS(Ubuntu under the hood), and get the same error as yours.
Then, I have fixed this error by following the steps at yarn official page, https://classic.yarnpkg.com/en/docs/install/#debian-stable
curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -
echo "deb https://dl.yarnpkg.com/debian/ stable main" | sudo tee /etc/apt/sources.list.d/yarn.list
Then,
sudo apt-get update
Finally,
sudo apt-get install yarn
I should say this error was a step two error, I first had this other highly related problem Vanilla Rails 6.0: "error Command "webpack" not found" and then I was led here.
Here is what I did to solve it. +32 was indeed coming from yarn
$ yarn --version
0.32+git
I tried to find the lucky combination of node/npm/yarn/webpack
but I never won anything at the lottery
so I removed yarn...
open your package.json in your favorite editor
make sure yarn is NOT there
delete yarn, or rename the binary
rails webpacker:install # now happy
rake assets:precompile # also happy
rails s # works fine again, I can use ActionCable finally.
npm ls -g
if no list yarn.
sudo npm install -g yarn --force
then
yarn --version
If you put 0.32+git as version number please try using a numeric version number, eg: 0.32 (drop the +git)
Try to update your Yarn version. Webpacker uses Yarn and it probably won't work with an old version, such as "0.32+git".
When I updated my version, the problem got solved and I could run the rails application.

Unable to run node_modules/.bin/browserifyinc. Ensure you have installed it with npm

Unable to run node_modules/.bin/browserifyinc. Ensure you have installed it with npm.
(in /Users/labuser/Downloads/betfair_nav_demo-master/app/assets/javascripts/application.js)
I am using Ampersand JS with Rails application.
gem 'rails', '4.2.1'
gem "browserify-rails", '1.2.0'
I have installed
npm install ampersand -g
npm install browserify --save-dev
npm install underscore --save
My Rails app is working without browserify-rails gem.
Try running
npm install browserify-incremental
It is best, however, to save this to a package.json file (so that when you deploy your code, you only have to run npm install, as you would bundle install).
If you don't have a package.json file, create one by running:
npm init
in your rails project's root directory.
Once you've done this, or if you already have a package.json file, you can save packages to it by running:
npm install --save <package_name>
If you have existing node packages installed in this project, npm init will automatically add these to your package.json file. If npm init prompts you for something that you're not sure of, or is not applicable to your application, just press enter and tidy up the package.json file afterwards. You should only ever need to run npm init once.

Error installing Protractor in ROR4 + AngularJS app various attempts

Using Ubuntu debian flavour, have been unsuccessfully trying to install protractor following:
the AngularJS official docs tutorial
by installing nodejs, npm and then downloading protractor from github repo as suggested here.
finally by installing the protractor-rails gem as per this SO.
I can see my nodejs version being: v0.10.25 and npm version being 1.3.10
however when I run either npm install protractor, or npm install -g protractor or follow the steps as per Protractor::Rails
in all cases I get the same error:
Ideas anyone?
Basically, this is a problem of permissions for creating directory.
You should try to set the permission on npm directory in your home dir.
sudo chown -R `whoami` ~/.npm
It is indeed a permissions issue coupled with some linux legacy code.
For those who may run into the same issue, a few steps to follow to sort this out:
the Debian installation has a legacy dir called node, this dir has to be removed and the package nodejs-legacy be installed instead.
Once nodejs-legacy has been installed, you may run the protractor installation (in your project folder) as follows:
sudo npm install -g protractor
once installation is finished check your
protractor --version
you should then get a Version 2.0.0 (as of today in my case)
You should be ready to update your webdriver and fire it up.

Resources