Dante-dan / nuxt-inline-scripts

Enable/Disable inlineScripts for Nuxt3
MIT License
1 stars 0 forks source link

Module Error encountered #2

Closed Dean-Christian-Armada closed 2 months ago

Dean-Christian-Armada commented 2 months ago

Current Behavior

I tried to do any npm commandslikenpm run build` but it returns an error. Please see error below:

[6:32:56 PM]  ERROR  Error while requiring module nuxt-inline-scripts: Error: Cannot find module '/Users/macbookpro/Documents/projects/unnotech/fucai3D/3d-nuxt/node_modules/nuxt-inline-scripts/src/index.js'. Please verify that the package.json has a valid "main" entry

[6:32:56 PM]  ERROR  Cannot find module '/Users/macbookpro/Documents/projects/unnotech/fucai3D/3d-nuxt/node_modules/nuxt-inline-scripts/src/index.js'. Please verify that the package.json has a valid "main" entry

  at tryPackage (node:internal/modules/cjs/loader:443:19)
  at Module._findPath (node:internal/modules/cjs/loader:713:18)
  at Module._resolveFilename (node:internal/modules/cjs/loader:1128:27)
  at Function.resolve (node:internal/modules/helpers:190:19)
  at Function._resolve [as resolve] (node_modules/.pnpm/jiti@1.21.6/node_modules/jiti/dist/jiti.js:1:241814)
  at resolveModule (node_modules/.pnpm/@nuxt+kit@3.13.0_magicast@0.3.4/node_modules/@nuxt/kit/dist/index.mjs:2234:29)
  at requireModule (node_modules/.pnpm/@nuxt+kit@3.13.0_magicast@0.3.4/node_modules/@nuxt/kit/dist/index.mjs:2239:24)
  at loadNuxtModuleInstance (node_modules/.pnpm/@nuxt+kit@3.13.0_magicast@0.3.4/node_modules/@nuxt/kit/dist/index.mjs:2518:92)
  at async installModule (node_modules/.pnpm/@nuxt+kit@3.13.0_magicast@0.3.4/node_modules/@nuxt/kit/dist/index.mjs:2470:47)
  at async initNuxt (node_modules/.pnpm/nuxt@3.13.0_eslint@8.57.0_sass@1.77.8_stylelint@15.11.0_stylus@0.63.0_typescript@5.5.4_vite@4.5.3/node_modules/nuxt/dist/index.mjs:4528:5)
  at async loadNuxt (node_modules/.pnpm/nuxt@3.13.0_eslint@8.57.0_sass@1.77.8_stylelint@15.11.0_stylus@0.63.0_typescript@5.5.4_vite@4.5.3/node_modules/nuxt/dist/index.mjs:4695:5)
  at async Module.loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:2571:19)
  at async Object.run (node_modules/.pnpm/nuxi@3.13.0/node_modules/nuxi/dist/chunks/build.mjs:77:18)
  at async runCommand$1 (node_modules/.pnpm/nuxi@3.13.0/node_modules/nuxi/dist/shared/nuxi.d8541eab.mjs:1648:16)
  at async runCommand$1 (node_modules/.pnpm/nuxi@3.13.0/node_modules/nuxi/dist/shared/nuxi.d8541eab.mjs:1639:11)
  at async runMain$1 (node_modules/.pnpm/nuxi@3.13.0/node_modules/nuxi/dist/shared/nuxi.d8541eab.mjs:1777:7)

Expected Behavior

Just a smooth sailing and as the purpose of the library, remove the window.__NUXT__ when doing View Page Source

Steps to Reproduce the Problem

  1. Enter pnpm add nuxt-inline-scripts -S
  2. Enter npm run build

Environment

Environment is only on localhost, I initially used yarn to libraries but when I did yarn add nuxt-inline-scripts.. I encountered the error:

[7:17:43 PM]  ERROR  Error while requiring module nuxt-inline-scripts: Error: Cannot find module '/Users/macbookpro/Documents/projects/unnotech/fucai3D/3d-nuxt/nuxt-inline-scripts'
Require stack:
- /Users/macbookpro/Documents/projects/unnotech/fucai3D/3d-nuxt/index.js

 ERROR  Cannot find module '/Users/macbookpro/Documents/projects/unnotech/fucai3D/3d-nuxt/nuxt-inline-scripts'                                                        7:17:43 PM
Require stack:
- /Users/macbookpro/Documents/projects/unnotech/fucai3D/3d-nuxt/index.js

  Require stack:
  - index.js
  at Module._resolveFilename (node:internal/modules/cjs/loader:1142:15)
  at Function.resolve (node:internal/modules/helpers:190:19)
  at Function._resolve [as resolve] (node_modules/jiti/dist/jiti.js:1:250334)
  at resolveModule (node_modules/@nuxt/kit/dist/index.mjs:2239:29)
  at requireModule (node_modules/@nuxt/kit/dist/index.mjs:2244:24)
  at loadNuxtModuleInstance (node_modules/@nuxt/kit/dist/index.mjs:2459:90)
  at async installModule (node_modules/@nuxt/kit/dist/index.mjs:2425:47)
  at async initNuxt (node_modules/nuxt/dist/index.mjs:3563:7)
  at async loadNuxt (node_modules/nuxt/dist/index.mjs:3646:5)
  at async Module.loadNuxt (node_modules/@nuxt/kit/dist/index.mjs:2571:19)
  at async Object.run (node_modules/nuxi/dist/chunks/build.mjs:67:18)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.9d864d83.mjs:1647:7)
  at async runCommand$1 (node_modules/nuxi/dist/shared/nuxi.9d864d83.mjs:1638:11)
  at async runMain$1 (node_modules/nuxi/dist/shared/nuxi.9d864d83.mjs:1770:7)

 ERROR  Cannot find module '/Users/macbookpro/Documents/projects/unnotech/fucai3D/3d-nuxt/nuxt-inline-scripts'                                                        7:17:43 PM
Require stack:
- /Users/macbookpro/Documents/projects/unnotech/fucai3D/3d-nuxt/index.js
Dean-Christian-Armada commented 2 months ago

Hello. @swaggy111 what for?

Dean-Christian-Armada commented 2 months ago

Looks like we got a hacker here @Dante-dan trying to inject viruses for penetration

Dante-dan commented 2 months ago

sorry, I set a error main entry

Dean-Christian-Armada commented 2 months ago

Hello @Dante-dan the hacker already remove his comments. He is asking me to download something to get my issues fixed. As for the error, looks like we will wait for your changes. Your library looks great

Dean-Christian-Armada commented 2 months ago

Hello, I installed the latest version of 1.0.9 I do not experience the main entry anymore but the inline is still there. Please see attached photo

Screen Shot 2024-08-28 at 3 40 11 AM

Below is part of my nuxt.config.ts

inlineScripts: {
    disable: true,
    // where inline scripts generate
    // output: '.output/public/_nuxt',
    // cdn url
    // cdnURL: string,
  },
  modules: [
    ['@pinia/nuxt', { autoImports: ['defineStore', 'mapState', 'mapActions'] }],
    'vue3-carousel-nuxt',
    ['@nuxtjs/eslint-module', { lintOnStart: false }],
    ['@nuxtjs/stylelint-module', { lintOnStart: false }],
    '@vant/nuxt',
    '@nuxtjs/device',
    'nuxt-inline-scripts',
  ],

Is there something I missed on my configration?

Dante-dan commented 2 months ago

yes, I'm fixing this problem. If the processing is completed, I will reply here.

Dante-dan commented 2 months ago

I fix this issue at nuxt-inline-scripts >= 1.0.13, you can try this package. And the dev mode is not supported yet.

You can also refer to this link: https://codesandbox.io/p/devbox/nuxt-inline-script-z4vjnf. Hope I can help you @Dean-Christian-Armada

Dean-Christian-Armada commented 2 months ago

Hello,

Your library does not support SSR? I can see that it is workign nice when ssr: false is configured in nuxt.config.ts.

Dante-dan commented 2 months ago

I have some issues for support SSR, because some inline scripts will be generated by server runtime. If this scripts will be exported to file, So when will they be deleted? Do you have some good idea ?

So I will give priority to SPA and Prerender Mode

Dean-Christian-Armada commented 2 months ago

I will see what I can do

Dante-dan commented 2 months ago

I will close this issue and open a new issue about SSR mode https://github.com/Dante-dan/nuxt-inlineScripts/issues/4

If you have any related questions, you can open this issue again 🚀