Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webpacker Issue after upgrading to 5.0 #1937

Closed
carltonsmith opened this issue Sep 13, 2020 · 15 comments
Closed

Webpacker Issue after upgrading to 5.0 #1937

carltonsmith opened this issue Sep 13, 2020 · 15 comments

Comments

@carltonsmith
Copy link

Steps to reproduce

  • Have running instance of Alchemy 4.6.1
  • Follow steps to upgrade to Alchemy 5.0
  • Launch Application

Expected behavior

Alchemy should load as usual

Actual behavior

Webpack error "Webpacker can't find alchemy/admin.js"

System configuration

  • Alchemy Version: 5.0
  • Rails Version: 6.0
@github-actions
Copy link

Hey. Thanks for reporting this issue and welcome to AlchemyCMS. The maintainer have been notified. Please be patient while waiting for an answer. Open Source is done by volunteers, so give them some time to react. Meanwhile please think about sending a PR that fixes this issue. It is way more likely that it will be accepted than this bug fixed for you. Remember OpenSource is done by all of us. Again, thanks for reporting.

@ck2000
Copy link

ck2000 commented Oct 19, 2020

I am having the same error. How did you fix this issue?

ActionView::Template::Error (Webpacker can't find alchemy/admin.js in ...../public/packs/manifest.json. Possible causes:

  1. You want to set webpacker.yml value of compile to true for your environment
    unless you are using the webpack -w or the webpack-dev-server.
  2. webpack has not yet re-run to reflect updates.
  3. You have misconfigured Webpacker's config/webpacker.yml file.
  4. Your webpack configuration is not creating a manifest.
    Your manifest contains:
    {
    "admin/application.js": "/packs/js/admin/application-87fafba140d37d015310.js",
    "admin/application.js.map": "/packs/js/admin/application-87fafba140d37d015310.js.map",
    "entrypoints": {
    "admin/application": {
    "js": [
    "/packs/js/admin/application-87fafba140d37d015310.js"
    ],
    "js.map": [
    "/packs/js/admin/application-87fafba140d37d015310.js.map"
    ]

@carltonsmith
Copy link
Author

I am having the same error. How did you fix this issue?

ActionView::Template::Error (Webpacker can't find alchemy/admin.js in ...../public/packs/manifest.json. Possible causes:

  1. You want to set webpacker.yml value of compile to true for your environment
    unless you are using the webpack -w or the webpack-dev-server.
  2. webpack has not yet re-run to reflect updates.
  3. You have misconfigured Webpacker's config/webpacker.yml file.
  4. Your webpack configuration is not creating a manifest.
    Your manifest contains:
    {
    "admin/application.js": "/packs/js/admin/application-87fafba140d37d015310.js",
    "admin/application.js.map": "/packs/js/admin/application-87fafba140d37d015310.js.map",
    "entrypoints": {
    "admin/application": {
    "js": [
    "/packs/js/admin/application-87fafba140d37d015310.js"
    ],
    "js.map": [
    "/packs/js/admin/application-87fafba140d37d015310.js.map"
    ]

I am still having the issue

@ck2000
Copy link

ck2000 commented Oct 19, 2020

I have created an empty file in app/assets/ajvascript/pack/alchemy/admin.js

This fixes the error. However I dont know if something else is missing...

@tvdeyen
Copy link
Member

tvdeyen commented Oct 19, 2020

Follow steps to upgrade to Alchemy 5.0

How did you exactly updated Alchemy?

The

bin/rake alchemy:upgrade

task should have added the npm module to your package.json file. It also should have ran

yarn install

If this is not the case then please add the npm module via

yarn add @alchemy_cms/admin

and try again.

@ck2000
Copy link

ck2000 commented Oct 19, 2020

I am having a fresh setup. Following your steps im getting the following error:

yarn install
yarn install v1.22.4
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] 🔍  Resolving packages...
success Already up-to-date.
✨  Done in 0.67s.
Christophs-iMac:trunk ck$ yarn add @alchemy/admin.js
yarn add v1.22.4
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] 🔍  Resolving packages...
error An unexpected error occurred: "https://registry.npmjs.org/@alchemy%2fadmin.js: Not found".
info If you think this is a bug, please open a bug report with the information provided in "/Users/ck/Projekte/payrollbox/trunk/yarn-error.log".
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this command.

@tvdeyen
Copy link
Member

tvdeyen commented Oct 19, 2020

I have created an empty file in app/assets/ajvascript/pack/alchemy/admin.js

This fixes the error. However I dont know if something else is missing...

That way you miss the features added as ES6 modules to the Alchemy admin.

Please remove that file and run

yarn add @alchemy_cms/admin

@ck2000
Copy link

ck2000 commented Oct 19, 2020

Thank you. I have added the package successfully.

yarn add v1.22.4
[1/4] 🔍 Resolving packages...
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 🔨 Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
└─ @alchemy_cms/admin@0.2.0
info All dependencies
└─ @alchemy_cms/admin@0.2.0
✨ Done in 7.16s.

However the error "ActionView::Template::Error (Webpacker can't find alchemy/admin.js" ... is still there. How does your rails asset.rb look like?

@tvdeyen
Copy link
Member

tvdeyen commented Oct 20, 2020

However the error "ActionView::Template::Error (Webpacker can't find alchemy/admin.js" ... is still there. How does your rails asset.rb look like?

Sprockets is not involved in the Webpack game. Is this locally? Then try to start the Webpack dev server

$ bin/webpack-dev-server

and try again.

@ck2000
Copy link

ck2000 commented Oct 20, 2020

Yes, this is in development / locally. The webpack dev server is running.


ℹ 「wds」: Project is running at http://localhost:3035/
ℹ 「wds」: webpack output is served from /packs/
ℹ 「wds」: Content not from webpack is served from /Users/.../trunk/public/packs
ℹ 「wds」: 404s will fallback to /index.html
ℹ 「wdm」: Hash: 83083d64d25f7c0a0e6f
Version: webpack 4.43.0
Time: 1290ms
Built at: 2020-10-20 9:25:32
                                           Asset       Size             Chunks                         Chunk Names
    js/admin/application-f3eb8d0a52d25ca0200a.js    761 KiB  admin/application  [emitted] [immutable]  admin/application
js/admin/application-f3eb8d0a52d25ca0200a.js.map    860 KiB  admin/application  [emitted] [dev]        admin/application
                                   manifest.json  406 bytes                     [emitted]              
ℹ 「wdm」: Compiled successfully.

I am still receiving this error. Something is still missing...

@dbwinger
Copy link
Contributor

dbwinger commented Mar 1, 2021

@ck2000 did you get this working? I'm currently upgrading to 5.0 and having this same problem. Added the yarn package (which wasn't automatically added by the ugprader) but still no luck and the same error:

Webpacker can't find alchemy/admin.js in xxx/public/packs/manifest.json

@ck2000
Copy link

ck2000 commented Mar 1, 2021

I have created the alchemy/admin.js file manually. You have to put it in here - just in case you are not familiar with webpacker - app/javascript/packs/alchemy/admin.js

The file runs the import of the yarn package:

import "@alchemy_cms/admin"

@dbwinger
Copy link
Contributor

dbwinger commented Mar 1, 2021

Thanks! I had actually just come across this method in the install generator which copies alchemy's admin.js into my app's javascript/packs dir: https://github.com/tvdeyen/alchemy_cms/blob/0df93dc9cdce472058d07fffb8d002cc9de08be8/lib/generators/alchemy/install/install_generator.rb#L94
I guess that's not set up to be copied automatically during the ugprade process. Maybe that should be documented in the upgrade message! @tvdeyen should that have happened automatically?

@tvdeyen
Copy link
Member

tvdeyen commented Mar 1, 2021

@dbwinger this should happen during upgrading as well. Thanks for pointing that out.

@afdev82
Copy link
Contributor

afdev82 commented Jun 10, 2021

I assume this can be closed now, the fix has been backported to v5.1 and v5.0 (by #2126 and #2125)

@tvdeyen tvdeyen closed this as completed Jun 10, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants