Import error when running `npx ask util generate-lwa-tokens`
noahbrenner opened this issue · comments
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request
[ ] Other... Please describe:
When running the generate-lwa-tokens
command, the process exits and a stack trace is shown due to what appears to be a missing internal module.
Expected Behavior
There should never be an error due to missing internal modules. The command should either succeed or display its own error message not caused by an unhandled internal error.
Current Behavior
An error stack is printed and the process exits with a status code of 1.
CLI Snapshot
I've replaced absolute paths to the project root directory with <repo>
in the output below:
$ npx ask util generate-lwa-tokens
node:internal/modules/cjs/loader:998
throw err;
^
Error: Cannot find module '@src/commands/util/upgrade-project'
Require stack:
- <repo>/node_modules/ask-cli/lib/commands/util/util-commander.js
- <repo>/node_modules/ask-cli/bin/ask-util.js
at Module._resolveFilename (node:internal/modules/cjs/loader:995:15)
at Module._resolveFilename (<repo>/node_modules/module-alias/index.js:49:29)
at Module._load (node:internal/modules/cjs/loader:841:27)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at <repo>/node_modules/ask-cli/lib/commands/util/util-commander.js:11:3
at Array.forEach (<anonymous>)
at Object.<anonymous> (<repo>/node_modules/ask-cli/lib/commands/util/util-commander.js:9:31)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'<repo>/node_modules/ask-cli/lib/commands/util/util-commander.js',
'<repo>/node_modules/ask-cli/bin/ask-util.js'
]
}
Node.js v18.12.1
$ echo $?
1
Steps to Reproduce (for bugs)
npm init -y
npm install -D ask-cli@2.28.0
npx ask util generate-lwa-tokens
The same error happens with or without --client-id
, --client-confirmation
, --scopes
, and --no-browser
.
When providing the additional options, I included the Amazon generated client ID and client secret for an existing Alexa skill.
I used --scopes "alexa::ask:skills:readwrite alexa::ask:models:readwrite"
Possible Solution
Is it possible that the package is configured to install differently when installed and run globally (npm install -g ask-cli && ask util generate-lwa-tokens
) vs locally in a project (npm install ask-cli && npx ask util generate-lwa-tokens
)?
If so, I'd suggest that this be changed. It's better to ensure that the same version is always used within a project instead of depending on global dependencies that aren't tracked within the project. It also simplifies CI/CD, by avoiding an additional install step separate from the project-level npm ci
/npm install
.
Your Environment and Context
- ask-cli version: 2.28.0
- Operating System and version: Ubuntu 22.04.2 LTS
- Node.js version used for development: 18.12.1
- NPM version used for development: 8.19.2
- Shell: GNU bash, version 5.1.16(1)-release (x86_64-pc-linux-gnu)
- This project is a monorepo. I get the same error whether running from the root project or the skill package directory.
thanks for reporting this bug, I was able to reproduce with 2.28.0 locally. I've checked and this doesn't reproduce on the latest release of the ask-cli, we took out all the @src
references.