Search code examples
djangovue.jsnpmbuildvagrant

How to solve the error while building a VueJS project?


I am using VueJS for front-end and Django on back-end. For production I moved all my VueJS compiled bundel to Static/dist in django. And I blocked the content of index.html in VueJS to base.html in django. And changed the url.py such that when localhost:8000 is called it gives base.html which gives index.html of VueJS.

When I am trying to build using npm run buid it is throwing errors as shown


ERROR  Build failed with errors.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! e_cell_frontend@0.1.0 build: `vue-cli-service build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the e_cell_frontend@0.1.0 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!     /home/vagrant/.npm/_logs/2021-08-05T04_54_44_578Z-debug.log

The log file is as shown:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'build' ]
2 info using npm@6.14.4
3 info using node@v10.19.0
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle e_cell_frontend@0.1.0~prebuild: e_cell_frontend@0.1.0
6 info lifecycle e_cell_frontend@0.1.0~build: e_cell_frontend@0.1.0
7 verbose lifecycle e_cell_frontend@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle e_cell_frontend@0.1.0~build: PATH: /usr/share/npm/node_modules/npm-lifecycle/node-gyp-bin:/home/vagrant/VueJS/e_cell_frontend/node_modules/.bin:/home/vagrant/.vscode-server/bin/c3f126316369cd610563c75b1b1725e0679adfb3/bin:/home/vagrant/.local/bin:/home/vagrant/.vscode-server/bin/c3f126316369cd610563c75b1b1725e0679adfb3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin
9 verbose lifecycle e_cell_frontend@0.1.0~build: CWD: /home/vagrant/VueJS/e_cell_frontend
10 silly lifecycle e_cell_frontend@0.1.0~build: Args: [ '-c', 'vue-cli-service build' ]
11 silly lifecycle e_cell_frontend@0.1.0~build: Returned: code: 1  signal: null
12 info lifecycle e_cell_frontend@0.1.0~build: Failed to exec build script
13 verbose stack Error: e_cell_frontend@0.1.0 build: `vue-cli-service build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:198:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/share/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:198:13)
13 verbose stack     at maybeClose (internal/child_process.js:982:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid e_cell_frontend@0.1.0
15 verbose cwd /home/vagrant/VueJS/e_cell_frontend
16 verbose Linux 5.4.0-73-generic
17 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "build"
18 verbose node v10.19.0
19 verbose npm  v6.14.4
20 error code ELIFECYCLE
21 error errno 1
22 error e_cell_frontend@0.1.0 build: `vue-cli-service build`
22 error Exit status 1
23 error Failed at the e_cell_frontend@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

I tried to clear the cache, delete node_modules and reinstalling them but there is no use. Can any one help me solving this problem.


Solution

  • I solved the problem. The thing is you need to remember that you need to run npm run serve first to check is there any errors in the code and then build it. I had a typo and forgot execute npm run serve so I am unaware of original errors. So run npm run server if all is good. The build it.