After creating a Vue.js project using Vue CLI 3 and setting up the import statement with the @
alias, I encountered an error when running npm run build
. Can you explain why this happened?
Error Message
$ npm run build
> [email protected] build /Users/???/Desktop/example
> vue-cli-service build
⠙ Building for production...Starting type checking and linting service...
Using 1 worker with 2048MB memory limit
⠼ Building for production...
ERROR Failed to compile with 1 errors 21:07:57
This dependency was not found:
* @/models/Member in ./node_modules/cache-loader/dist/cjs.js??ref--13-0!./node_modules/thread-loader/dist/cjs.js!./node_modules/
babel-loader/lib!./node_modules/ts-loader??ref--13-3!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader
/lib??vue-loader-options!./src/main/javascript/components/Vote.vue?vue&type=script&lang=ts&
To install it, you can run: npm install --save @/models/Member
ERROR Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the [email protected] build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/???.npm/_logs/2019-04-30T12_07_57_611Z-debug.log
Files
tsconfig.json
"paths": {
"@/*": [
"src/main/javascript/*",
"src/test/javascript/*"
]
},
src/main/javascript/models/Member.ts
export default class Member {
...
}
src/main/javascript/components/Vote.vue
import Member from '@/models/Member'; // import error
Source Code: https://github.com/yoshikit1996/vuejs-exercise
Syntax Highlight
My VSCode can detect import error but didn't detect it with @
alias.