1

I am trying to create the absolute basic new vue-cli project, on Linux. The generated project won't run. What am I doing wrong?

I installed the most recent vue cli

sudo npm install -g @vue/[email protected]

I created a new project:

cd /tmp
vue create project1

I selected the default presets.

I tried to run the project

$ cd project1

$ npm run serve

> [email protected] serve /tmp/project1
> vue-cli-service serve

 INFO  Starting development server...
 ERROR  Error: Cannot find module 'babel-code-frame'
Error: Cannot find module 'babel-code-frame'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
    at Function.Module._load (internal/modules/cjs/loader.js:562:25)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/usr/share/nodejs/eslint/lib/formatters/codeframe.js:8:19)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
    at Module.load (internal/modules/cjs/loader.js:653:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
    at Function.Module._load (internal/modules/cjs/loader.js:585:3)
    at Module.require (internal/modules/cjs/loader.js:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at exports.loadModule (/tmp/project1/node_modules/@vue/cli-shared-utils/lib/module.js:79:14)
    at api.chainWebpack.webpackConfig (/tmp/project1/node_modules/@vue/cli-plugin-eslint/index.js:59:26)
    at webpackChainFns.forEach.fn (/tmp/project1/node_modules/@vue/cli-service/lib/Service.js:236:40)
    at Array.forEach (<anonymous>)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] serve: `vue-cli-service serve`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] serve 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/kevin/.npm/_logs/2020-07-24T17_38_02_618Z-debug.log

My npm version is 6.14.7

$ npm --version
6.14.7

This is package.json after manually hacking in "@babel/code-frame" as suggested by Igor.

{
  "name": "project1",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "core-js": "^3.6.5",
    "vue": "^2.6.11"
  },
  "devDependencies": {
    "@babel/code-frame": "^7.10.4",
    "@vue/cli-plugin-babel": "~4.5.0",
    "@vue/cli-plugin-eslint": "~4.5.0",
    "@vue/cli-service": "~4.5.0",
    "babel-eslint": "^10.1.0",
    "eslint": "^6.7.2",
    "eslint-plugin-vue": "^6.2.2",
    "vue-template-compiler": "^2.6.11"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "parserOptions": {
      "parser": "babel-eslint"
    },
    "rules": {}
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not dead"
  ]
}

I tried clearing down npm cache as per this ticket, but it didn't make a difference.

https://stackoverflow.com/questions/42308879/npm-err-code-elifecycle
4
  • install it with npm install --save-dev @babel/code-frame Commented Jul 24, 2020 at 18:11
  • Thanks, I tried that, and it makes no difference. This ends up in the devDependencies, but no build. "@babel/code-frame": "^7.10.4". Commented Jul 24, 2020 at 18:20
  • uninstall vue cli with: sudo npm uninstall -g @vue/[email protected], then install again with npm install -g @vue/cli. NO SUDO. you should not install npm packages with sudo. then create the project again as usual Commented Jul 24, 2020 at 18:52
  • I created a new virtualbox vm using Ubuntu 20.04. I ran the same commands (including with the sudo), and everything worked OK, so my conclusion is that there is something wrong on my PC, rather than wrong with NPM/VUE. I am going to see if I can mark this question as invalid. Commented Jul 24, 2020 at 20:01

1 Answer 1

4

I removed and reinstalled nodejs and npm to solve the problem.

sudo apt-get remove npm
sudo apt-get remove nodejs

Re-install

sudo apt-get update
sudo apt-get install nodejs npm
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.