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

unable to install module #301

Open
fago opened this issue Jan 18, 2025 · 10 comments
Open

unable to install module #301

fago opened this issue Jan 18, 2025 · 10 comments

Comments

@fago
Copy link
Contributor

fago commented Jan 18, 2025

after update the demo, it fails to load the module:

npm run build

> build
> nuxt build

Nuxt 3.15.2 with Nitro 2.10.4                                                                                                                                           nuxi 4:13:00 AM

 ERROR  Could not load nuxtjs-drupal-ce. Is it installed?    

see drunomics/lupus-decoupled-nuxt3-demo#68 + the launch link there

Temporary for releases

git checkout v2.1.2 -- package*
git commit -am "tmp comit"
npm version VERSION
npm publish
@fago
Copy link
Contributor Author

fago commented Jan 18, 2025

testing this in another environment, I can reproduce the problem.

Also, when trying to add the module via nuxi add I get the same error

Need to install the following packages:
[email protected]
Ok to proceed? (y) y

ℹ Resolved nuxtjs-drupal-ce, adding module...                   nuxi 22:30:15
ℹ nuxtjs-drupal-ce is already installed                         nuxi 22:30:15
ℹ nuxtjs-drupal-ce is already in the modules                    nuxi 22:30:15

 ERROR  Could not load nuxtjs-drupal-ce. Is it installed?             22:30:16

    at loadNuxtModuleInstance (node_modules/@nuxt/kit/dist/index.mjs:2472:11)
    at async installModule (node_modules/@nuxt/kit/dist/index.mjs:2395:67)
    at async initNuxt (node_modules/nuxt/dist/shared/nuxt.BoHAox-C.mjs:5339:5)
    at async loadNuxt (node_modules/nuxt/dist/shared/nuxt.BoHAox-C.mjs:5527:5)
    at async loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:2642:19)
    at async Object.run (/home/iris/.npm/_npx/b95349761371180e/node_modules/nuxi/dist/chunks/prepare.mjs:47:18)
    at async runCommand$1 (/home/iris/.npm/_npx/b95349761371180e/node_modules/nuxi/dist/shared/nuxi.Dy8tIv7d.mjs:1767:16)
    at async runCommand (/home/iris/.npm/_npx/b95349761371180e/node_modules/nuxi/dist/shared/nuxi.Dy8tIv7d.mjs:2094:10)
    at async Object.setup (/home/iris/.npm/_npx/b95349761371180e/node_modules/nuxi/dist/chunks/add2.mjs:150:5)
    at async runCommand$1 (/home/iris/.npm/_npx/b95349761371180e/node_modules/nuxi/dist/shared/nuxi.Dy8tIv7d.mjs:1739:5)
    at async runCommand$1 (/home/iris/.npm/_npx/b95349761371180e/node_modules/nuxi/dist/shared/nuxi.Dy8tIv7d.mjs:1758:11)
    at async runCommand$1 (/home/iris/.npm/_npx/b95349761371180e/node_modules/nuxi/dist/shared/nuxi.Dy8tIv7d.mjs:1758:11)
    at async runMain$1 (/home/iris/.npm/_npx/b95349761371180e/node_modules/nuxi/dist/shared/nuxi.Dy8tIv7d.mjs:1896:7) 



 ERROR  Could not load nuxtjs-drupal-ce. Is it installed? 

@fago
Copy link
Contributor Author

fago commented Jan 18, 2025

testing whether undoing the non-major dep updates before release fixes it, by releasing 2.2.1-rc.2 - it does not :-/

@fago
Copy link
Contributor Author

fago commented Jan 19, 2025

ok, I was able to workaround by it with this

git checkout v2.1.2 -- package*
git commit -am "tmp comit"
npm version VERSION
npm publish

and then run the release process. So something broke with the upgrades, probably some files are not included. Let's fix this.

For reference, this is the output of a working publish process

npm notice
npm notice 📦  [email protected]
npm notice Tarball Contents
npm notice 1.1kB LICENSE
npm notice 11.3kB README.md
npm notice 1.1kB bin/nuxt-drupal-ce-init.cjs
npm notice 227B dist/module.cjs
npm notice 734B dist/module.d.mts
npm notice 734B dist/module.d.ts
npm notice 214B dist/module.json
npm notice 2.7kB dist/module.mjs
npm notice 1.3kB dist/runtime/composables/useDrupalCe/index.d.ts
npm notice 10.3kB dist/runtime/composables/useDrupalCe/index.js
npm notice 435B dist/runtime/composables/useDrupalCe/server.d.ts
npm notice 440B dist/runtime/composables/useDrupalCe/server.js
npm notice 124B dist/runtime/server/api/drupalCe.d.ts
npm notice 629B dist/runtime/server/api/drupalCe.js
npm notice 124B dist/runtime/server/api/menu.d.ts
npm notice 384B dist/runtime/server/api/menu.js
npm notice 125B dist/runtime/server/middleware/drupalFormHandler.d.ts
npm notice 1.3kB dist/runtime/server/middleware/drupalFormHandler.js
npm notice 54B dist/runtime/server/plugins/errorLogger.d.ts
npm notice 737B dist/runtime/server/plugins/errorLogger.js
npm notice 58B dist/types.d.mts
npm notice 55B dist/types.d.ts
npm notice 1.1kB package.json
npm notice 38B playground/app.vue
npm notice 1.2kB playground/components/Drupal/DrupalTabs.vue
npm notice 411B playground/components/global/drupal-form--default.vue
npm notice 208B playground/components/global/drupal-markup.vue
npm notice 1.9kB playground/components/global/drupal-pagination.vue
npm notice 444B playground/components/global/drupal-view--default.vue
npm notice 526B playground/components/global/node--default.vue
npm notice 765B playground/components/Navigation/NavigationMain.vue
npm notice 751B playground/components/Site/SiteBreadcrumbs.vue
npm notice 1.5kB playground/components/Site/SiteLanguageSwitcher.vue
npm notice 665B playground/components/Site/SiteMessage.vue
npm notice 835B playground/components/Site/SiteMessages.vue
npm notice 494B playground/pages/[...slug].vue
npm notice 948B playground/pages/[entity]/[id]/layout-preview.client.vue
npm notice 909B playground/pages/preview/[...slug].client.vue
npm notice Tarball Details
npm notice name: nuxtjs-drupal-ce
npm notice version: 2.2.1-rc.3
npm notice filename: nuxtjs-drupal-ce-2.2.1-rc.3.tgz
npm notice package size: 14.6 kB
npm notice unpacked size: 46.8 kB
npm notice shasum: 1b8243f3e344cc2ac35a68c03096e32d1b9d2776
npm notice integrity: sha512-v1c+IJ2wYtAbW[...]v9ZxM/ij9ckQQ==
npm notice total files: 38
npm notice
npm notice Publishing to https://registry.npmjs.org/ with tag latest and default access
+ [email protected]

@fago
Copy link
Contributor Author

fago commented Jan 19, 2025

not working example

ℹ Stubbing nuxtjs-drupal-ce                                          20:51:46
ℹ Cleaning dist directory: ./dist                                    20:51:46
npm notice
npm notice 📦  [email protected]
npm notice Tarball Contents
npm notice 1.1kB LICENSE
npm notice 11.3kB README.md
npm notice 1.1kB bin/nuxt-drupal-ce-init.cjs
npm notice 227B dist/module.cjs
npm notice 171B dist/module.d.ts
npm notice 209B dist/module.json
npm notice 472B dist/module.mjs
npm notice 436B dist/types.d.mts
npm notice 430B dist/types.d.ts
npm notice 1.2kB package.json
npm notice 38B playground/app.vue
npm notice 1.1kB playground/components/Drupal/DrupalTabs.vue
npm notice 1.9kB playground/components/Drupal/DrupalViewsPagination.vue
npm notice 411B playground/components/global/drupal-form--default.vue
npm notice 753B playground/components/global/drupal-layout.vue
npm notice 208B playground/components/global/drupal-markup.vue
npm notice 447B playground/components/global/drupal-view--default.vue
npm notice 526B playground/components/global/node--default.vue
npm notice 765B playground/components/Navigation/NavigationMain.vue
npm notice 751B playground/components/Site/SiteBreadcrumbs.vue
npm notice 1.5kB playground/components/Site/SiteLanguageSwitcher.vue
npm notice 665B playground/components/Site/SiteMessage.vue
npm notice 835B playground/components/Site/SiteMessages.vue
npm notice 494B playground/pages/[...slug].vue
npm notice 948B playground/pages/[entity]/[id]/layout-preview.client.vue
npm notice 909B playground/pages/preview/[...slug].client.vue
npm notice Tarball Details
npm notice name: nuxtjs-drupal-ce
npm notice version: 2.2.1
npm notice filename: nuxtjs-drupal-ce-2.2.1.tgz
npm notice package size: 10.1 kB
npm notice unpacked size: 28.9 kB
npm notice shasum: 7d81121f79631ca2371944436a398dd53ddd5d8d
npm notice integrity: sha512-Hyv8cn2igOeDV[...]gud2FPYtz2guA==
npm notice total files: 26
npm notice
npm notice Publishing to https://registry.npmjs.org/ with tag latest and default access
+ [email protected]

@fago
Copy link
Contributor Author

fago commented Jan 19, 2025

v2.2.2 publishing I got working, but now a new problem: It errors out with "useHead is not defined" all the time. weirdly in the playgroudn it works just fine. Trying to fix by adding an import for it.

@fago
Copy link
Contributor Author

fago commented Jan 19, 2025

that helped. but next error:

 ERROR  [nitro] [unhandledRejection] defineComponent is not defined

    at renderCustomElements (node_modules/nuxtjs-drupal-ce/dist/runtime/composables/useDrupalCe/index.js:178:7)
    at node_modules/nuxtjs-drupal-ce/dist/runtime/composables/useDrupalCe/index.js:191:16

weirdly the nuxt playground has not issue like this. so next try is to import defineComponent also
adding #302

@fago
Copy link
Contributor Author

fago commented Jan 19, 2025

v2.2.4 finally works!

still, the problem of this issue (module loading) is relevant and releases are broken without the noted workaround of using packages of last 2.1.* release for publishing. So that needs fixing

@maximilianmikus
Copy link
Contributor

can you pinpoint which dependency update is the issue?

@TurtlBbx
Copy link
Contributor

TurtlBbx commented Jan 21, 2025

@fago Yes, you need to explicitly import stuff for a published Nuxt module. Otherwise it errors out (is not defined) when using the module in a project. With Nuxt playground, auto importing works, so no errors there.

Quote from Nuxt docs:

Published modules cannot leverage auto-imports for assets within their runtime directory. Instead, they have to import them explicitly from #imports or alike.
Indeed, auto-imports are not enabled for files within node_modules (the location where a published module will eventually live) for performance reasons.
If you are using the module starter, auto-imports will not be enabled in your playground either.

source: Module Author Guide

@StirStudios
Copy link

I have stumbled across a random issue. One out of three projects with the same code set give me a usePageHead is not a function when using the new setup:

const { fetchPage, renderCustomElements, usePageHead, getPageLayout } =
  useDrupalCe()
const page = await fetchPage(useRoute().path, { query: useRoute().query })
const layout = getPageLayout(page)
const { isAdministrator, bodyClasses } = usePageContext(page)
usePageHead(page)

However as soon as we revert back to the useHead

useHead({
  htmlAttrs: {
    lang: 'en',
  },
  bodyAttrs: {
    class: bodyClasses,
  },
  title: page.value.title,
  meta: page.value.metatags.meta,
  link: page.value.metatags.link,
  script: [
    {
      type: 'application/ld+json',
      children: JSON.stringify(page.value.metatags.jsonld || []),
    },
  ],
})

Everything is fine again.

When I run console logs I get:

useDrupalCe resolved: Object$ceApi: (fetchOptions = {}) => {…}fetchMenu: async (name, useFetchOptions = {}, overrideErrorHandler) => {…}fetchPage: async (path, useFetchOptions = {}, overrideErrorHandler) => {…}getCeApiEndpoint: (localize = true) => {…}getDrupalBaseUrl: () => {…}getMenuBaseUrl: () => {…}getMessages: () => useState("drupal-ce-messages", () => [])getPage: () => useState("drupal-ce-page-data", () => ({}))getPageLayout: (page) => {…}passThroughHeaders: (nuxtApp, pageHeaders) => {…}renderCustomElements: (customElements) => {…}useCeApi: (path, fetchOptions = {}, doPassThroughHeaders) => {…}[[Prototype]]: Object
default.vue:8 usePageHead resolved: undefined

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants