acquia / next-acms

ACMS with fully or progressively decoupled front-end
MIT License
19 stars 9 forks source link

Consider using npm instead of yarn #28

Open balsama opened 2 years ago

balsama commented 2 years ago

As someone unfamiliar with modern JS development, my experience:

  1. Most instructions are for npm (e.g., on npmjs.com itself)
  2. Anecdotally, yarn seems to be more forgiving - in a bad way. I ended up with incompatible versions of dependencies and a cursory search turned up that yarn allowed something that npm wouldn't have. I don't have documentation of steps to prove this though
  3. It introduces another tool. You already need node, which comes with npm. Using yarn adds another tool.

I'm curious what others' experiences are and also what (if anything) the decision to choose yarn over npm was based on.

fiasco commented 2 years ago

I've been using npm as I don't have yarn running locally. What am I missing out on?

lauriii commented 2 years ago

I tested the monorepo setup with npm just to see if this would be feasible. It seems like building packages works which is great. However, something goes wrong on how turbo executes the dev watch command:

$ npm run dev

> dev
> turbo run dev --parallel

• Packages in scope: next-acms, next-acms-basic-starter
• Running dev in 2 packages
next-acms-basic-starter:dev: cache bypass, force executing 5b915c950c2bc687
next-acms:dev: cache bypass, force executing 61bd45dec486c53c
next-acms:dev:
next-acms:dev: > next-acms@1.0.0-alpha1 dev
next-acms:dev: > microbundle watch --no-compress --jsx React.createElement
next-acms:dev:
next-acms-basic-starter:dev:
next-acms-basic-starter:dev: > next-acms-basic-starter@1.0.0 dev
next-acms-basic-starter:dev: > NODE_OPTIONS='--inspect' next dev
next-acms-basic-starter:dev:
next-acms:dev: Starting inspector on 127.0.0.1:9229 failed: address already in use
next-acms-basic-starter:dev: Debugger listening on ws://127.0.0.1:9229/ae7ce11d-fbd3-4c82-a0cb-5e6ed28e2e15
next-acms-basic-starter:dev: For help, see: https://nodejs.org/en/docs/inspector
next-acms-basic-starter:dev: warn  - Port 3000 is in use, trying 3001 instead.
next-acms:dev: ready - started server on 0.0.0.0:3000, url: http://localhost:3000
next-acms-basic-starter:dev: ready - started server on 0.0.0.0:3001, url: http://localhost:3001
next-acms-basic-starter:dev: info  - Loaded env from /Users/lauri.eskola/Projects/next-acquia-cms/starters/basic-starter/.env.local
next-acms:dev: Error: > Couldn't find a `pages` directory. Please create one under the project root
next-acms:dev:     at Object.findPagesDir (/Users/lauri.eskola/Projects/next-acquia-cms/node_modules/next/dist/lib/find-pages-dir.js:39:15)
next-acms:dev:     at new DevServer (/Users/lauri.eskola/Projects/next-acquia-cms/node_modules/next/dist/server/dev/next-dev-server.js:137:73)
next-acms:dev:     at NextServer.createServer (/Users/lauri.eskola/Projects/next-acquia-cms/node_modules/next/dist/server/next.js:106:20)
next-acms:dev:     at /Users/lauri.eskola/Projects/next-acquia-cms/node_modules/next/dist/server/next.js:121:42
next-acms:dev:     at async NextServer.prepare (/Users/lauri.eskola/Projects/next-acquia-cms/node_modules/next/dist/server/next.js:96:24)
next-acms:dev:     at async /Users/lauri.eskola/Projects/next-acquia-cms/node_modules/next/dist/cli/next-dev.js:127:9
next-acms:dev: npm ERR! Lifecycle script `dev` failed with error:
next-acms:dev: npm ERR! Error: command failed
next-acms:dev: npm ERR!   in workspace: next-acms@1.0.0-alpha1
next-acms:dev: npm ERR!   at location: /Users/lauri.eskola/Projects/next-acquia-cms/packages/next-acms
next-acms:dev: ERROR: command finished with error: command (packages/next-acms) npm run dev exited (1)

This is probably something that could be resolved but I won't jump into this right now.

lauriii commented 2 years ago

I believe this is at least partially resolved since we removed the yarn.lock file on https://github.com/acquia/next-acms/pull/50. This means that both npm and yarn are supported equally by the basic-starter. For example, documentation in dev.acquia.com is already recommending to use npm.

We are still using yarn internally for development, at least for now. In order to reduce confusion, we should continue to recommend using yarn within this repository until the monorepo is converted to use npm.

lauriii commented 2 years ago

Discussed this with @fiasco and we agreed that this has been sufficiently addressed for the GA now that the basic-starter is agnostic about package manager and can be used with both yarn and npm. I'm leaving this open since for better maintainer experience, we might want to consider switching to npm, but we should not block the GA on that.