0

i have two env files in my vue js project

- .env.development
- .env.production

i want to build the project with command npm run build --mode development or npm run build --mode production for build based on my env files based on vue docs.

and i get this error

Entry module not found: Error: Can't resolve '/var/www/html/projectname/production' in '/var/www/html/projectname'

what is the solution??

sinak
  • 222
  • 6
  • 19
  • [duplicate](https://stackoverflow.com/questions/11580961/sending-command-line-arguments-to-npm-script) ; `npm run build -- --mode development` – birdspider Jan 24 '20 at 13:33
  • Does this answer your question? [Sending command line arguments to npm script](https://stackoverflow.com/questions/11580961/sending-command-line-arguments-to-npm-script) – birdspider Jan 24 '20 at 13:34
  • @birdspider id dont think so – sinak Jan 24 '20 at 13:36

1 Answers1

4

Your file setup seem correct, it looks like you need to change your command from this:

npm run build --mode production

to this

npm run build -- --mode production

According to this github thread: https://github.com/vuejs/vue-cli/issues/1528#issuecomment-395970443

Copying the comment there:

"In other words: all arguments before -- are interpreted as arguments for npm itself, not the script you are running."


Alternatively, if you don't use the npm script shortcut, you can use vue-cli-service directly:

vue-cli-service build --mode production
d-_-b
  • 21,536
  • 40
  • 150
  • 256