0
votes

Framework: VueJS

OS: Linux Mint 19.2

NPM version 3.5.2

Creating a web app (client and server hosted locally)

Likely cause of error: strict linting?

I'm a Visual C# .NET developer and I'm trying to get caught up with this new wave of web development and have decided to go with VUE for my first framework.

I'm pretty sure that where I went wrong was setting up the linting settings. The instructor was prompted with very different questions than I was during the 'npm install' command. Linting error keeps causing me to crash.

This is the error log:

0 info it worked if it ends with ok

1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'lint' ]

2 info using [email protected]

3 info using [email protected]

4 verbose run-script [ 'prelint', 'lint', 'postlint' ]

5 info lifecycle [email protected]~prelint: [email protected]

6 silly lifecycle [email protected]~prelint: no script for prelint, continuing

7 info lifecycle [email protected]~lint: [email protected]

8 verbose lifecycle [email protected]~lint: unsafe-perm in lifecycle true

9 verbose lifecycle [email protected]~lint: PATH: /usr/share/npm/bin/node-gyp-bin:/home/user/...

10 verbose lifecycle [email protected]~lint: CWD: /home/user/Documents/Projects/tab-tracker/server

11 silly lifecycle [email protected]~lint: Args: [ '-c', 'eslint **/*.js' ]

12 silly lifecycle [email protected]~lint: Returned: code: 2 signal: null

13 info lifecycle [email protected]~lint: Failed to exec lint script

14 verbose stack Error: [email protected] lint: eslint **/*.js

14 verbose stack Exit status 2

...

The client is running just fine,

This is my 'package.json within the server:

    {
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "start": "./node_modules/nodemon/bin/nodemon.js src/app.js --exec 'npm run lint && node'",
    "lint": "./node_modules/.bin/eslint **/*.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "morgan": "^1.9.1"
  },
  "devDependencies": {
    "eslint-config-standard": "^10.2.1",
    "eslint-plugin-import": "^2.7.0",
    "eslint-plugin-node": "^5.1.1",
    "eslint-plugin-promise": "^3.5.0",
    "eslint-plugin-standard": "^3.0.1",
    "nodemon": "^2.0.2",
    "eslint": "^6.8.0"
  }
}

The top of my eslint module indicates it is set to strict:

#!/usr/bin/env node

"use strict";

...

Here is the console output after I run

`sudo npm start`

in my server folder

I guinely spent a lot of time trying to debug this before coming here for help. I feel very confidant that I setuo my linting options to be overly strict.

1

1 Answers

0
votes

The 'Prettier' extension in VS Code will remove whitespace that the linter requires and cause the linting to fail

Uninstall Prettier and if you need a 'Beautify' option, use one that is designed for VueJS. It should go without saying but make sure you aren't using a TS linter on a JS codebase and vice versa.

In the code listed above:

Remove the linting:

Before:

  "scripts": {
    "start": "./node_modules/nodemon/bin/nodemon.js src/app.js --exec 'npm run lint && node'",
    "lint": "./node_modules/.bin/eslint **/*.js"
  },

After (fix):

  "scripts": {
    "start": "./node_modules/nodemon/bin/nodemon.js src/app.js --exec 'npm run && node'"
},

I don't think this is going to lint but it will at least allow the app to run

I suspect a version incompatibility issue or just running Linux while following an OSX guide. But this worked for me.