Moovweb XDN CLI Error: Cannot find module 'decode-uri-component'

Running through the getting started with Vue.js docs throws an error on xdn init

internal/modules/cjs/loader.js:628
  throw err;
  ^Error: Cannot find module 'decode-uri-component'
Require stack:
- /Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/serverless/serveStaticAssets.js
- /Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/utils/runWithServerless.js
- /Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/utils/runDeploymentArchive.js
- /Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/commands/run.js
- /Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/node_modules/yargs/index.js
- /Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/index.js
  at Function.Module._resolveFilename (internal/modules/cjs/loader.js:625:15)
  at Function.Module._load (internal/modules/cjs/loader.js:527:27)
  at Module.require (internal/modules/cjs/loader.js:683:19)
  at require (internal/modules/cjs/helpers.js:16:16)
  at Object.<anonymous> (/Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/serverless/serveStaticAssets.js:13:28)
  at Module._compile (internal/modules/cjs/loader.js:776:30)
  at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10)
  at Module.load (internal/modules/cjs/loader.js:643:32)
  at Function.Module._load (internal/modules/cjs/loader.js:556:12)
  at Module.require (internal/modules/cjs/loader.js:683:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
  '/Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/serverless/serveStaticAssets.js',
  '/Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/utils/runWithServerless.js',
  '/Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/utils/runDeploymentArchive.js',
  '/Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/commands/run.js',
  '/Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/node_modules/yargs/index.js',
  '/Users/moladukes/.nvm/versions/node/v12.6.0/lib/node_modules/@xdn/cli/index.js'
]
}

upgrading from node version 12.6 to node 12.18 resolved this

@howie.ross
I am also facing the same error.
I upgraded the node version to v14.15.0
but it still persists.

Is there any other fix for this error?

1 Like

@howie.ross I’m facing the same issue. I just update to Node LTS v14.15.0. And the docs said XDN only supports Node.js version 12 and higher

Have you tried?

npm i -g --save 'decode-uri-component'

Generally this is the way to solve issues where modules aren’t found.

1 Like

Looks like decode-uri-component was missing from the package.json in @xdn/cli. Will be fixed shortly. In the meantime, just installing that module globally should work as a workaround.

1 Like

As an aside, while you can run locally with Node v14.x, the cloud project will be run under Node v12.x so it is recommended you use that.

1 Like

Thanks, @mark.brocato and @ianand. I still ran into an issue with “modules not found” (which can’t be solved by installing), in which case I had to use nvm and Node 12.18.4.

We’ve pushed out a fix for this. Please run npm i -g @xdn/cli@latest and retry xdn init.

1 Like

The error persists for me on Node version 14.15.0

Did you try the latest @xdn/cli?

Yes, I did. I see the package update here on npm with version number 2.27.4 and Node version 14.15.0

I tried running xdn init on a next app with the latest cli and it works fine for me. I think something may be wrong with your node setup. From the stack track it looks like it’s trying to install and run @xdn/next globally. That should not be the case. The last thing you could try is:

npm i --D @xdn/cli@latest
npx xdn init

That will install the latest CLI within your project and run init locally instead of globally.

1 Like

Perfect @mark.brocato It works now.