Redwood: Missing dependency lodash-decorators after `rwt copy`

Created on 21 Jul 2020  ·  16Comments  ·  Source: redwoodjs/redwood

After building RW and copying it over to a project I get an error about a missing dependency

tobbe@XPS9550 MINGW64 ~/dev/redwood/redwood-testing (master)
$ yarn rw test
yarn run v1.22.4
$ C:\Users\tobbe\dev\redwood\redwood-testing\node_modules\.bin\rw test
internal/modules/cjs/loader.js:1032
  throw err;
  ^

Error: Cannot find module 'lodash-decorators'
Require stack:
- C:\Users\tobbe\dev\redwood\redwood-testing\node_modules\@redwoodjs\structure\dist\x\decorators.js
- C:\Users\tobbe\dev\redwood\redwood-testing\node_modules\@redwoodjs\structure\dist\ide.js
- C:\Users\tobbe\dev\redwood\redwood-testing\node_modules\@redwoodjs\structure\dist\index.js
- C:\Users\tobbe\dev\redwood\redwood-testing\node_modules\@redwoodjs\cli\dist\commands\diagnostics.js
- C:\Users\tobbe\dev\redwood\redwood-testing\node_modules\yargs\index.js
- C:\Users\tobbe\dev\redwood\redwood-testing\node_modules\@redwoodjs\cli\dist\index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:1029:15)
    at Function.Module._load (internal/modules/cjs/loader.js:898:27)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at Object.<anonymous> (C:\Users\tobbe\dev\redwood\redwood-testing\node_modules\@redwoodjs\structure\dist\x\decorators.js:32:25)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    'C:\\Users\\tobbe\\dev\\redwood\\redwood-testing\\node_modules\\@redwoodjs\\structure\\dist\\x\\decorators.js',
    'C:\\Users\\tobbe\\dev\\redwood\\redwood-testing\\node_modules\\@redwoodjs\\structure\\dist\\ide.js',
    'C:\\Users\\tobbe\\dev\\redwood\\redwood-testing\\node_modules\\@redwoodjs\\structure\\dist\\index.js',
    'C:\\Users\\tobbe\\dev\\redwood\\redwood-testing\\node_modules\\@redwoodjs\\cli\\dist\\commands\\diagnostics.js',
    'C:\\Users\\tobbe\\dev\\redwood\\redwood-testing\\node_modules\\yargs\\index.js',
    'C:\\Users\\tobbe\\dev\\redwood\\redwood-testing\\node_modules\\@redwoodjs\\cli\\dist\\index.js'
  ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

Is anyone else seeing this? Or is it just me? Is it (yet another) Windows issue?

I can work around it by going in to node_modules/@redwoodjs/structure and running yarn install, but that only fixes it until I run rwt copy again

bu2-confirmed

All 16 comments

I haven't noticed this myself - could you try yarn install --force in your redwood framework?

In ~/dev/redwood/redwood (framework dir)
yarn install --force
yarn build
yarn test

Everything works fine

In ~/dev/redwood/redwood-testing (project using rw)
yarn rwt copy ../redwood
yarn rw test

And I still get that same error as posted above

FYI - I am seeing the same error w/ exact same behavior/steps.

What I have to do is:

in my local redwood fork:

  • yarn build

in my local redwood app:

  • yarn rwt copy ..path
  • yarn install --force
  • yarn rw dev

and after each time I copy I have to install --force (a simple yarn install doesn't work)

Hmpf... Wouldn't yarn install --force in your project directory overwrite the things that yarn rwt copied over?

@Tobbe Have you created the required jest.config.js files for yarn rw test?

Oh .. 🤦‍♂️ ... of course ... no wonder it works. ;)

I have created jest.config.js in web and api as well.

Super weird, does this happen when you try to run yarn rw dev as well?

Super weird, does this happen when you try to run yarn rw dev as well?

Yes.

I am rummaging through the packages ... I don't fully follow everything ... but would core need to have structure as a dependency?

core's package.json

"@redwoodjs/cli": "^0.14.0",
    "@redwoodjs/dev-server": "^0.14.0",
    "@redwoodjs/eslint-config": "^0.14.0",
    "@redwoodjs/internal": "^0.14.0",
    "@redwoodjs/testing": "^0.14.0",
    "@storybook/react": "^5.3.19",

of dev-server's?

It should be a dependency of cli

have you upgraded to v0.14.0?

Last night I yarn rw upgraded my local dev app to v0.14.0, can see it is using:

  "devDependencies": {
    "@redwoodjs/core": "^0.14.0",

and then this morning I fetches my fork of redwood to latest:

  • I see code for the new diagnostics CLI command
  • and my core package has
    "@redwoodjs/cli": "^0.14.0",
    "@redwoodjs/dev-server": "^0.14.0",
    "@redwoodjs/eslint-config": "^0.14.0",
    "@redwoodjs/internal": "^0.14.0",
    "@redwoodjs/testing": "^0.14.0",

And then that's what's being copied over

and I see same:

internal/modules/cjs/loader.js:716
    throw err;
    ^

Error: Cannot find module 'lodash-decorators'
Require stack:
- /Users/dthyresson/Dropbox (Personal)/projects/redwoodjs/deployed/node_modules/@redwoodjs/structure/dist/x/decorators.js
- /Users/dthyresson/Dropbox (Personal)/projects/redwoodjs/deployed/node_modules/@redwoodjs/structure/dist/ide.js
- /Users/dthyresson/Dropbox (Personal)/projects/redwoodjs/deployed/node_modules/@redwoodjs/structure/dist/index.js
- /Users/dthyresson/Dropbox (Personal)/projects/redwoodjs/deployed/node_modules/@redwoodjs/cli/dist/commands/diagnostics.js
- /Users/dthyresson/Dropbox (Personal)/projects/redwoodjs/deployed/node_modules/yargs/index.js
- /Users/dthyresson/Dropbox (Personal)/projects/redwoodjs/deployed/node_modules/@redwoodjs/cli/dist/index.js

So. I think so.

Just a heads up that I'm able to reproduce this now.

A temporary work around is to installed it as a dev dependency: yarn add -DW lodash-decorators

I fixed this by deleting yarn.lock and node_modules in my framework repo and installing the dependencies.

878 should fix this issue, so if you update to main, you should go OK now.

Confirmed, works now 👍

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tmeasday picture tmeasday  ·  4Comments

peterp picture peterp  ·  4Comments

balaji-balu picture balaji-balu  ·  3Comments

weaversam8 picture weaversam8  ·  4Comments

thedavidprice picture thedavidprice  ·  3Comments