Home > Mobile >  Forked VueJS app gives error on npm install
Forked VueJS app gives error on npm install

Time:10-09

So this company gave me the assignment to build a simple Vue app. I forked code from their repo and tried to run npm install. But It gave me couple errors that is in this log file. Also here is my package.json file:

{
  "name": "todo-app",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "test:unit": "vue-cli-service test:unit",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "axios": "^0.21.1",
    "core-js": "^3.6.5",
    "vue": "^3.0.0",
    "vue-router": "^4.0.0-0",
    "vuex": "^4.0.0-0"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-plugin-router": "~4.5.0",
    "@vue/cli-plugin-unit-jest": "~4.5.0",
    "@vue/cli-plugin-vuex": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "@vue/compiler-sfc": "^3.0.0",
    "@vue/test-utils": "^2.0.0-0",
    "autoprefixer": "^9.8.6",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^7.0.0",
    "jest-transform-stub": "^2.0.0",
    "node-sass": "^4.12.0",
    "postcss": "^7.0.36",
    "sass-loader": "^8.0.2",
    "tailwindcss": "npm:@tailwindcss/postcss7-compat@^2.2.7",
    "typescript": "~3.9.3",
    "vue-jest": "^5.0.0-0"
  }
}

Here are couple extra information if those are necessary:

  • npm version : 7.21.1
  • @vue/cli version : 4.5.13
  • Node version : 16.0.0

Part of error

5827 verbose stack Error: command failed
5827 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/index.js:64:27)
5827 verbose stack     at ChildProcess.emit (node:events:365:28)
5827 verbose stack     at maybeClose (node:internal/child_process:1067:16)
5827 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
5828 verbose pkgid [email protected]
5829 verbose cwd /home/yarkin/Documents/WEB/VueJS/todo-app
5830 verbose Linux 5.11.0-37-generic
5831 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "--saveDev" "[email protected]"
5832 verbose node v16.0.0
5833 verbose npm  v7.21.1
5834 error code 1
5835 error path /home/yarkin/Documents/WEB/VueJS/todo-app/node_modules/node-sass
5836 error command failed
5837 error command sh -c node scripts/build.js
5838 error Building: /usr/local/bin/node /home/yarkin/Documents/WEB/VueJS/todo-app/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=

CodePudding user response:

The problem is specific to node-sass, in this project it seems to be the only binary dependency that depends on a platform and Node version.

There is a message that lock file version is old, this means that it was created with another version of NPM (v6), this can be is a possible source of problems due to differences in resolved dependencies.

As the documentation lists, different node-sass versions are linked to different Node versions, "node-sass": "^4.12.0" suggests that the project is supposed to run with Node v12, while v16 was used.

Possible solutions are:

  • Switch to Node v12 for this project (can be too old for other ones) and run as is

  • Switch to Node v14 (the latest LTS release, less problems in general) and update node-sass to ^4.14

  • Stay with Node v16 and update node-sass to ^6.0

  • Stay with Node v16, remove node-sass, instead add platform-independent sass, follow migration guidelines for Dart Sass if problems arise (primarily / syntax)

  • Related