plone / volto

React-based frontend for the Plone Content Management System
https://demo.plone.org/
MIT License
468 stars 629 forks source link

Use create-yo trampoline in documentation #2067

Open tiberiuichim opened 3 years ago

tiberiuichim commented 3 years ago

So, it appears that it's actually possible to bootstrap a Volto project "hands-free", no prerequisite installed package by running:

npm init yo @plone/volto

and this works also:

npm init yo @plone/volto:addon

So I propose that we tweak our documentation and recommend this approach as default.

tiberiuichim commented 3 years ago

The trick here is npm init yo will look for a create-yo package, which then delegates to @plone/volto yo generator

nileshgulia1 commented 3 years ago

@tiberiuichim npm init yo @plone/volto <project-name> doesn't seem to succeed.

In file included from ../fsevents.cc:6:
In file included from ../../nan/nan.h:2884:
../../nan/nan_typedarray_contents.h:34:43: warning: 'GetContents' is deprecated: Use GetBackingStore. See http://crbug.com/v8/9908.
      [-Wdeprecated-declarations]
      data   = static_cast<char*>(buffer->GetContents().Data()) + byte_offset;
                                          ^
/Users/nileshgulia/Library/Caches/node-gyp/14.15.4/include/node/v8.h:5272:3: note: 'GetContents' has been explicitly marked deprecated here
  V8_DEPRECATE_SOON("Use GetBackingStore. See http://crbug.com/v8/9908.")
  ^
/Users/nileshgulia/Library/Caches/node-gyp/14.15.4/include/node/v8config.h:402:39: note: expanded from macro 'V8_DEPRECATE_SOON'
# define V8_DEPRECATE_SOON(message) [[deprecated(message)]]
                                      ^
1 warning generated.
info looking for cached prebuild @ /Users/nileshgulia/.npm/_prebuilds/82ff49-iltorb-v2.4.5-node-v83-darwin-x64.tar.gz
http request GET https://github.com/nstepien/iltorb/releases/download/v2.4.5/iltorb-v2.4.5-node-v83-darwin-x64.tar.gz
http 404 https://github.com/nstepien/iltorb/releases/download/v2.4.5/iltorb-v2.4.5-node-v83-darwin-x64.tar.gz
WARN install No prebuilt binaries found (target=14.15.4 runtime=node arch=x64 libc= platform=darwin)
warning ../../../../../../../package.json: No license field                                                                                                  
command not found: volto
✔ create-yo ok!

whereas npm init yo @plone/volto works as expected.

tiberiuichim commented 3 years ago

without the project name in the command line

pnicolli commented 3 years ago

yarn create yo @plone/volto works as well

fredvd commented 3 years ago

`scaffoldtest fred$ nvm use 14 Now using node v14.17.1 (npm v7.7.0) scaffoldtest fred$ yarn create yo @plone/volto yarn create v1.22.11 [1/4] 🔍 Resolving packages... [2/4] 🚚 Fetching packages... [3/4] 🔗 Linking dependencies... [4/4] 🔨 Building fresh packages... success Installed "create-yo@2.0.0" with binaries:

Error: Cannot find module 'libnpx' Require stack:

info Visit https://yarnpkg.com/en/docs/cli/create for documentation about this command.

ls -alh /usr/local/bin/create-yo lrwxr-xr-x 1 fred admin 67B Aug 9 20:53 /usr/local/bin/create-yo -> ../../../Users/fred/.config/yarn/global/node_modules/.bin/create-yo

Mini1:scaffoldtest fred$ which yarn /Users/fred/.nvm/versions/node/v14.17.1/bin/yarn

`

tiberiuichim commented 3 years ago

I can replicate the Fred's problem on ArchLinux as well.

tiberiuichim commented 3 years ago

https://github.com/boneskull/create-yo/issues/4

fredvd commented 3 years ago

@ericof @tiberiuichim @sneridagh

We have new round of trainings for PloneConf 2021 and this bug is popping up again for some of the participants when they need to scaffold a Volto project.

And we do have some trainings that now have `'npm init yo @plone/volto" as their scaffolding example. :-/

It happened at least to 2 people in the deployment training and it's now happening also to me. I've done some testing on my local Mac and an Ubuntu 18.04 and it is is not (only) related to OS X . We have a node version and an npm version. And node comes with a bundled npm which you can update.

I first tested it was the node.js LTS16, then it seemed to be npm8, but narrowing it down further the missing npx errorst start with v16.12.0 + npm>6. installing any npm6/7/8 in v16.10.0 and the yo generator still starts.

Maybe it's for this reason that www.nodejs.org is still listing 14 as the latest LTS when according to the scheme LTS16 is current? :-O

fredvd commented 3 years ago

We'll probably never be able to find the ultimate 'install instructions' that always work. Just discussed the details of this particular issue at PLOG, but the real issue is that it is a pain to keep all the bootstrapping instructions in the Plone trainings up to date.

Proposed fix: what if we create a 'mini' Plone training for training.plone.org that only lists the current working bootstrapping instructions for our Plone project environments:

And for each describe commmon issues you might encounter because of situation x,y whatever.

Then we can/should remove detailed bootstrapping instructions from the other trainings and put references in their introductions to the bootstrapping training. "To scaffold a new volto project', follow the current instructions here".

Then when an issue pops up like using yo with npx being broken on LTS > 16.10.0 we only have to maintain/update 1 training.

We could also discuss that this should be on docs.plone.org, but training.plone.org is maybe closer and more visible while you're starting a training. (& 'internal' link')

tiberiuichim commented 3 years ago

With the addons training, I managed to avoid the fiasco: https://training.plone.org/5/voltoaddons/01-addon-basics.html#bootstrap-a-new-volto-project (though in this year's edition there was limited participation).

Yeah, I think it's best if we just let go of npm init yo @plone/volto and just promote the simple, two step process from the above training.

fredvd commented 3 years ago

@tiberiuichim The 'challenge' with your approach is that I think I did exactly this approach when I participated in the first volto addons training in 2020. And it caused problems when I did another training this year:

I didn't really use my laptop during covid and when I participated in the Volto Deployment training this weekend with my laptop, I unknowingly resued my nvm based LTS 14 installation from last year. It had the older version of create-yo (3) globally installed and it broke the scaffolding questions and threw tracebacks or created subtle errors by not adding extra volto-addons to all the places in the packaage.json. It only started working when I wiped the nvm nodejs environment, removing create-yo@3 and installing create-yo@4 on the demand with the 'npm init yo' . Took me an hour to figure this out and lagged behind with following the training.

So somehow if an older create-yo is already there it isn't updated. Mabye this is a bug in our generate dependencies or in yo's dependencies. Just to demonstrate (n=1) that also these 'failsafe' instructions could cause future issues.

fredvd commented 3 years ago

Meanwhile @ericof had a report of someone using node.js LTS14 with npm 8.1.0 throwing the npx error, n=1 one, but my conclusion that it is only > nodejs 16.10.0 is obviously wrong. But maybe things get fixed when you do

npm install -g npm@6 npm install -g npm@8

because it then pulls in the npx package while instaling npm@6 and then you reinstall npm@8 again. Just guessing :-O

tiberiuichim commented 3 years ago
npm install -g yo
npm install -g @plone/generator-volto
yo @plone/volto volto-tutorial-project

wouldn't use create-yo. If that npx is too dificult, let's avoid npm init and directly use yo, which is easier to control (make sure to upgrade yo before)

HillLiu commented 2 years ago

There is a simple solution with zero dependencies, and only use node native modules.

such as...

npx yonpx @plone/volto volto-tutorial-project
fredvd commented 2 years ago

Breaks right away with the 'cannot find libnpx' error message.....

npx yonpx @plone/volto volto-tutorial-project
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'libnpx'
Require stack:
- /Users/fred/.nvm/versions/node/v16.13.1/bin/node_modules/npm/node_modules/libnpx/noop.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/fred/.npm/_npx/f1e212ed1c50d94c/node_modules/yonpx/src/init.js:16:34)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/fred/.nvm/versions/node/v16.13.1/bin/node_modules/npm/node_modules/libnpx/noop.js'
  ]
}
npm -g list
/Users/fred/.nvm/versions/node/v16.13.1/lib
├── corepack@0.10.0
└── npm@8.1.2

node -v
v16.13.1
nileshgulia1 commented 2 years ago

Hm.. works for me with node v14.x

HillLiu commented 2 years ago

Look like node 16 change the npx invoke way, I'll help fix it.

HillLiu commented 2 years ago

@fredvd quick verify on node 14 and 16, it should be resolved.

Breaks right away with the 'cannot find libnpx' error message.....

npx yonpx @plone/volto volto-tutorial-project
node:internal/modules/cjs/loader:936
  throw err;
  ^

Error: Cannot find module 'libnpx'
Require stack:
- /Users/fred/.nvm/versions/node/v16.13.1/bin/node_modules/npm/node_modules/libnpx/noop.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/fred/.npm/_npx/f1e212ed1c50d94c/node_modules/yonpx/src/init.js:16:34)
    at Module._compile (node:internal/modules/cjs/loader:1101:14)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/Users/fred/.nvm/versions/node/v16.13.1/bin/node_modules/npm/node_modules/libnpx/noop.js'
  ]
}
npm -g list
/Users/fred/.nvm/versions/node/v16.13.1/lib
├── corepack@0.10.0
└── npm@8.1.2

node -v
v16.13.1

#