Меню

Npm run serve vue ошибка

I am getting an error when trying to run npm run serve. At first I installed node.js then vue as well as vue/cli.
But when I am trying to run server as -> npm run serve at that time I’m getting error like ‘vue-cli-service’ is not recognized as an internal or external command.

I used below codes for installation:

npm install -g vue
npm install -g @vue/cli

enter image description here

can someone guide me what to do to solve this issue ?

asked Oct 27, 2019 at 13:27

Dcoder14's user avatar

Dcoder14Dcoder14

1,7413 gold badges11 silver badges22 bronze badges

3

I think you are using cmd in windows.

Try deleting the node_modules folder and after that run npm i from the cmd.

Then try running npm run serve again and see if it works this time

answered Oct 27, 2019 at 14:44

s4k1b's user avatar

s4k1bs4k1b

2,8351 gold badge7 silver badges14 bronze badges

7

Install vue/cli-service globally

npm install @vue/cli-service -g

This will install global npm package.

@vue/cli-service is usully installed as global, because you do not usually copy these types of packages to every project.

If the global npm package gets corrupted, it is not stored in node_modules folder, but rather in other depending on the os. Therefore removing node_modules does not help. Locations for global node_modules folders are

  • %USERPROFILE%AppDataRoamingnpmnode_modules (Win10) or
  • /usr/local/lib/node_modules (Linux),

check this stack overflow post on how to locate global packages.

answered May 26, 2020 at 15:14

Scholtz's user avatar

ScholtzScholtz

2,4151 gold badge20 silver badges22 bronze badges

2

it will depend on the package manager you are using

  1. delete node_modules

  2. if you are using yarn run yarn or yarn install and then yarn serve

  3. if you are using npm run npm install and then npm run serve

answered Aug 29, 2020 at 13:40

Ntwari Clarance Liberiste's user avatar

In my case, the package @vue/cli-service is installed in my local node_modules environment, but not my global environment, so it cannot be used as a command. I type .node_modules.binvue-cli-service serve and it works.

answered Apr 9, 2020 at 3:52

Lucien Zhang's user avatar

As it is mentioned in terminal that node_modules is missing from your project, so you can’t directly use npm run serve, first you have to do npm install then do npm run serve. It will work fine

answered Apr 18, 2020 at 12:45

Shubham Sharma's user avatar

1

In my case I ran below commands in GitBash and it worked fine

  1. npm install
  2. npm run serve

answered Oct 30, 2020 at 19:18

Kiran Modini's user avatar

  1. If you are using cmd in windows.
  2. deleting the node_modules folder and after that run npm istall from
    the cmd.
  3. run npm run serve and see if it works this time

answered Dec 17, 2020 at 16:25

Ali Raza's user avatar

Ali RazaAli Raza

6225 silver badges14 bronze badges

In my case, I have checked the folder of node_modules was missing. I am using Windows. So I run this in cmd.

  1. npm install
  2. npm run serve

Then I check it in localhost like usual.

answered Jun 19, 2021 at 21:31

ahartami's user avatar

This issue mostly happens when either @vue/cli is not installed or in most cases,

@vue/cli is already installed and you are currently working on a project and when running

  • yarn serve or npm run serve.

Most at times, this issue is been caused by broken dependencies.
to fix this issue, simple run

  • yarn install or npm install

depending on your package manager.

answered Aug 13, 2021 at 3:10

Romanric Akam's user avatar

well after trying all the solutions above and it still haven’t worked for you then you probably have a stupid space in the full directory of your Vue project like in my case. so remove that that space and it will work from then on.

answered Aug 28, 2021 at 20:51

Muhammad Kashif's user avatar

Remember to set the NODE_ENV=development and run npm install again

answered Sep 18, 2021 at 4:57

William Keller's user avatar

Try changing the project path to one without spaces, it worked on windows 10

answered Nov 12, 2021 at 16:15

Maher Fakhour's user avatar

I had faced the same problem in windows. Then
first I deleted the node_module. then I run npm install.

answered Nov 3, 2020 at 4:01

Hasibul-'s user avatar

Hasibul-Hasibul-

1,1121 gold badge9 silver badges17 bronze badges

For Windows you should modify package.json to:

  "scripts": {
    "serve": "vue-cli-service.cmd serve",
    "build": "vue-cli-service.cmd build",
    "lint": "vue-cli-service.cmd lint"
  }

,

answered Mar 22, 2021 at 20:30

Andrey -hidden-'s user avatar

I had the same issue using windows + WSL2 (Ubuntu 20.04). Looking at the logs generated after trying to run npm i I noticed that my WSL2 environment did not have python2 installed. So to solve I ran the following commands:

  1. sudo apt-get install python2
  2. rm -rf node_modules
  3. npm i
  4. npm run serve

answered May 3, 2021 at 10:38

Sales Lopes's user avatar

I faced the same in Windows. Had to run npm install again. Then it worked perfectly.

answered May 28, 2021 at 9:56

burke_'s user avatar

Wait, what’s the difference between @vue/cli and @vue/cli-service? When you install both, they show different number of packages installed. The latter solved my issue actually but everyone keeps saying install @vue/cli.

answered Aug 19, 2021 at 20:04

Justin Farrugia's user avatar

try running npm i or npm install and then proceed to run npm i vue after previous installation done. works for me

answered Jun 18, 2022 at 6:03

rubanero14's user avatar

you need use «npm install» at Command Line

answered Aug 27, 2022 at 16:39

beginnerZ's user avatar

Before running «npm install», try running this command first:

npm set strict-ssl false

answered Nov 4, 2022 at 14:35

ShieldOfSalvation's user avatar

Like you, I got the error below when I ran npm run serve from the CMD command line,

‘vue-cli-service’ is not recognized as an internal or external
command, operable program or batch file.

I got past this familiar error by using the following command to add the npm folder to the PATH that CMD searches for executables:

path=%path%;C:Users<USERNAME>AppDataRoamingnpm

where <USERNAME> is your Windows user profile directory name. Only then was I able to run the following commands successfully:

npm install 
npm run serve

answered Dec 9, 2022 at 20:20

ShieldOfSalvation's user avatar

What solved the issue for me was renaming the directory. I had used the symbol «&» on the folder name and it seems to break things, so changing it to «and» fixed the issue.

This will probably be an incredibly niche thing, but if I help even 1 person it’s fine by me.

answered Dec 30, 2022 at 22:15

N1h1l1sT's user avatar

N1h1l1sTN1h1l1sT

951 silver badge11 bronze badges

I have a project, I can run it well on Linux, but i have the same issue on windows, I solve it this way (I hope in your case it works too):

  1. Delete the node_modules

  2. Install it again with npm i

Stefano Sansone's user avatar

answered Nov 2, 2021 at 13:59

Ismael Gomez's user avatar

1

Version

4.1.1

Environment info

System:
    OS: Windows 7 6.1.7601
    CPU: (4) x64 Intel(R) Core(TM) i5-4200U CPU @ 1.60GHz
  Binaries:
    Node: 10.14.2 - C:Program Filesnodejsnode.EXE
    Yarn: Not Found
    npm: 6.5.0 - C:Program Filesnodejsnpm.CMD
  npmGlobalPackages:
    @vue/cli: Not Found

@vue/cli 4.1.1 is actually installed globally and vue command is available.

Steps to reproduce

Create a project using vue create
  • vue create my-project
Go the directory my-project
  • cd my-project
Run my-project with serve
  • npm run serve

What is expected?

The project should start in development mode with hot reload.

What is actually happening?

The command terminates without starting anything.
If we run vue serve instead of npm run serve, it errors out the following in the terminal and exits:

Failed to locate entry file in my/project/directory/path.
Valid entry file should be one of: main.js, index.js, App.vue or app.vue.

So I am assuming npm run serve tries to find either of the above mentioned files but is not able to find any and hence terminates. The reason is, none of the «entry» files are in the project’s root directory but inside the src directory.

I created a client project for vue and run npm run serve,
but got this error:

Tried to reinstall node,npm, edited some PATHS, but nothing worked

Version

3.2.1

Node and OS info

Node v10.14.0/ npm 6.4.1

    0 info it worked if it ends with ok
    1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'serve' ]
    2 info using npm@6.4.1
    3 info using node@v10.14.0
    4 verbose run-script [ 'preserve', 'serve', 'postserve' ]
    5 info lifecycle client@0.1.0~preserve: client@0.1.0
    6 info lifecycle client@0.1.0~serve: client@0.1.0
    7 verbose lifecycle client@0.1.0~serve: unsafe-perm in lifecycle true
    8 verbose lifecycle client@0.1.0~serve: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/alexsexotic/Desktop/work/Test - mongod:node/client/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Users/alexsexotic/.npm-global/bin
    9 verbose lifecycle client@0.1.0~serve: CWD: /Users/alexsexotic/Desktop/work/Test - mongod:node/client
    10 silly lifecycle client@0.1.0~serve: Args: [ '-c', 'vue-cli-service serve' ]
    11 info lifecycle client@0.1.0~serve: Failed to exec serve script
    12 verbose stack Error: client@0.1.0 serve: `vue-cli-service serve`
    12 verbose stack spawn ENOENT
    12 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
    12 verbose stack     at ChildProcess.emit (events.js:182:13)
    12 verbose stack     at maybeClose (internal/child_process.js:962:16)
    12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
    13 verbose pkgid client@0.1.0
    14 verbose cwd /Users/alexsexotic/Desktop/work/Test - mongod:node/client
    15 verbose Darwin 17.2.0
    16 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "serve"
    17 verbose node v10.14.0
    18 verbose npm  v6.4.1
    19 error file sh
    20 error code ELIFECYCLE
    21 error errno ENOENT
    22 error syscall spawn
    23 error client@0.1.0 serve: `vue-cli-service serve`
    23 error spawn ENOENT
    24 error Failed at the client@0.1.0 serve script.
    24 error This is probably not a problem with npm. There is likely additional logging output above.
    25 verbose exit [ 1, true ]

asked Nov 29, 2018 at 9:56

Alex Nguyen's user avatar

Alex NguyenAlex Nguyen

611 gold badge2 silver badges4 bronze badges

8

You may check your current cli installation and maybe reinstall your vue-cli. Basically, an npx command runs within your project directory. So running npx [whatever] will always use modules installed within your project itself while npm run [whatever] may refer to some globally installed dependencies.

That said, you might also try using yarn. In the past I’ve also had some trouble running vue-cli through npm so I switched to yarn.

However I can not help you regarding your index.html problem since this may be another issue. But if you’ve bootstrapped a fresh vue project throughout vue-cli, it should work.

answered Nov 29, 2018 at 14:12

Aer0's user avatar

Aer0Aer0

3,71217 silver badges33 bronze badges

5

You can try this:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

It’s work for me.

answered Mar 25, 2020 at 9:05

Hongjinfen's user avatar

I created a client project for vue and run npm run serve,
but got this error:

Tried to reinstall node,npm, edited some PATHS, but nothing worked

Version

3.2.1

Node and OS info

Node v10.14.0/ npm 6.4.1

    0 info it worked if it ends with ok
    1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'serve' ]
    2 info using npm@6.4.1
    3 info using node@v10.14.0
    4 verbose run-script [ 'preserve', 'serve', 'postserve' ]
    5 info lifecycle client@0.1.0~preserve: client@0.1.0
    6 info lifecycle client@0.1.0~serve: client@0.1.0
    7 verbose lifecycle client@0.1.0~serve: unsafe-perm in lifecycle true
    8 verbose lifecycle client@0.1.0~serve: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/alexsexotic/Desktop/work/Test - mongod:node/client/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Frameworks/Python.framework/Versions/3.7/bin:/Users/alexsexotic/.npm-global/bin
    9 verbose lifecycle client@0.1.0~serve: CWD: /Users/alexsexotic/Desktop/work/Test - mongod:node/client
    10 silly lifecycle client@0.1.0~serve: Args: [ '-c', 'vue-cli-service serve' ]
    11 info lifecycle client@0.1.0~serve: Failed to exec serve script
    12 verbose stack Error: client@0.1.0 serve: `vue-cli-service serve`
    12 verbose stack spawn ENOENT
    12 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
    12 verbose stack     at ChildProcess.emit (events.js:182:13)
    12 verbose stack     at maybeClose (internal/child_process.js:962:16)
    12 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
    13 verbose pkgid client@0.1.0
    14 verbose cwd /Users/alexsexotic/Desktop/work/Test - mongod:node/client
    15 verbose Darwin 17.2.0
    16 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "serve"
    17 verbose node v10.14.0
    18 verbose npm  v6.4.1
    19 error file sh
    20 error code ELIFECYCLE
    21 error errno ENOENT
    22 error syscall spawn
    23 error client@0.1.0 serve: `vue-cli-service serve`
    23 error spawn ENOENT
    24 error Failed at the client@0.1.0 serve script.
    24 error This is probably not a problem with npm. There is likely additional logging output above.
    25 verbose exit [ 1, true ]

asked Nov 29, 2018 at 9:56

Alex Nguyen's user avatar

Alex NguyenAlex Nguyen

611 gold badge2 silver badges4 bronze badges

8

You may check your current cli installation and maybe reinstall your vue-cli. Basically, an npx command runs within your project directory. So running npx [whatever] will always use modules installed within your project itself while npm run [whatever] may refer to some globally installed dependencies.

That said, you might also try using yarn. In the past I’ve also had some trouble running vue-cli through npm so I switched to yarn.

However I can not help you regarding your index.html problem since this may be another issue. But if you’ve bootstrapped a fresh vue project throughout vue-cli, it should work.

answered Nov 29, 2018 at 14:12

Aer0's user avatar

Aer0Aer0

3,71217 silver badges33 bronze badges

5

You can try this:

echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p

It’s work for me.

answered Mar 25, 2020 at 9:05

Hongjinfen's user avatar

Ошибка:
> vuehello@0.1.0 serve
> vue-cli-service serve

INFO Starting development server…
10% building 2/4 modules 2 active C:UsersomaraOneDriveРабочий столvuejsnode_moduleswebpackhotdev-server.jsError: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:130:10)
at module.exports (C:UsersomaraOneDriveРабочий столvuejsnode_moduleswebpacklibutilcreateHash.js:135:53)
at NormalModule._initBuildHash (C:UsersomaraOneDriveРабочий столvuejsnode_moduleswebpacklibNormalModule.js:417:16)
at handleParseError (C:UsersomaraOneDriveРабочий столvuejsnode_moduleswebpacklibNormalModule.js:471:10)
at C:UsersomaraOneDriveРабочий столvuejsnode_moduleswebpacklibNormalModule.js:503:5
at C:UsersomaraOneDriveРабочий столvuejsnode_moduleswebpacklibNormalModule.js:358:12
at C:UsersomaraOneDriveРабочий столvuejsnode_modulesloader-runnerlibLoaderRunner.js:373:3
at iterateNormalLoaders (C:UsersomaraOneDriveРабочий столvuejsnode_modulesloader-runnerlibLoaderRunner.js:214:10)
at iterateNormalLoaders (C:UsersomaraOneDriveРабочий столvuejsnode_modulesloader-runnerlibLoaderRunner.js:221:10)
at C:UsersomaraOneDriveРабочий столvuejsnode_modulesloader-runnerlibLoaderRunner.js:236:3
at runSyncOrAsync (C:UsersomaraOneDriveРабочий столvuejsnode_modulesloader-runnerlibLoaderRunner.js:130:11)
at iterateNormalLoaders (C:UsersomaraOneDriveРабочий столvuejsnode_modulesloader-runnerlibLoaderRunner.js:232:2)
at Array. (C:UsersomaraOneDriveРабочий столvuejsnode_modulesloader-runnerlibLoaderRunner.js:205:4)
at Storage.finished (C:UsersomaraOneDriveРабочий столvuejsnode_modulesenhanced-resolvelibCachedInputFileSystem.js:55:16)
at C:UsersomaraOneDriveРабочий столvuejsnode_modulesenhanced-resolvelibCachedInputFileSystem.js:91:9
node:internal/crypto/hash:67
this[kHandle] = new _Hash(algorithm, xofLen);
^

Error: error:0308010C:digital envelope routines::unsupported
at new Hash (node:internal/crypto/hash:67:19)
at Object.createHash (node:crypto:130:10)
at module.exports (C:UsersomaraOneDriveРабочий столvuejsnode_moduleswebpacklibutilcreateHash.js:135:53)
at NormalModule._initBuildHash (C:UsersomaraOneDriveРабочий столvuejsnode_moduleswebpacklibNormalModule.js:417:16)
at handleParseError (C:UsersomaraOneDriveРабочий столvuejsnode_moduleswebpacklibNormalModule.js:471:10)
at C:UsersomaraOneDriveРабочий столvuejsnode_moduleswebpacklibNormalModule.js:503:5
at C:UsersomaraOneDriveРабочий столvuejsnode_moduleswebpacklibNormalModule.js:358:12
at C:UsersomaraOneDriveРабочий столvuejsnode_modulesloader-runnerlibLoaderRunner.js:373:3
at iterateNormalLoaders (C:UsersomaraOneDriveРабочий столvuejsnode_modulesloader-runnerlibLoaderRunner.js:214:10)
at Array. (C:UsersomaraOneDriveРабочий столvuejsnode_modulesloader-runnerlibLoaderRunner.js:205:4)
at Storage.finished (C:UsersomaraOneDriveРабочий столvuejsnode_modulesenhanced-resolvelibCachedInputFileSystem.js:55:16)
at C:UsersomaraOneDriveРабочий столvuejsnode_modulesenhanced-resolvelibCachedInputFileSystem.js:91:9
at C:UsersomaraOneDriveРабочий столvuejsnode_modulesgraceful-fsgraceful-fs.js:123:16
at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error’ ],
library: ‘digital envelope routines’,
reason: ‘unsupported’,
code: ‘ERR_OSSL_EVP_UNSUPPORTED’
}

Node.js v17.1.0

Package.json:
{
«name»: «vuehello»,
«version»: «0.1.0»,
«private»: true,
«scripts»: {
«serve»: «vue-cli-service serve»,
«build»: «vue-cli-service build»
},
«dependencies»: {
«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-router»: «~4.5.0»,
«@vue/cli-plugin-vuex»: «~4.5.0»,
«@vue/cli-service»: «~4.5.0»,
«@vue/compiler-sfc»: «^3.0.0»
},
«browserslist»: [
«> 1%»,
«last 2 versions»,
«not dead»
]

I just installed Node.js and Vue.js and created my first project on Vue called test . I am now trying to set up the server by typing on cmd:

npm run server

But I get the following error:

C:Usersandritest>npm run server
npm ERR! missing script: server

npm ERR! A complete log of this run can be found in:
npm ERR!     C:UsersandriAppDataRoamingnpm-cache_logs2019-02-19T09_12_53_961Z-debug.log

Could anyone help me understand what I am missing? I googled a bit around, but have not been able to find a solution so far. I appreciate, any help!

EDIT: This is my package.json file

{
  "name": "test",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "vue": "^2.5.22"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.4.0",
    "@vue/cli-plugin-eslint": "^3.4.0",
    "@vue/cli-service": "^3.4.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.8.0",
    "eslint-plugin-vue": "^5.0.0",
    "vue-template-compiler": "^2.5.21"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}
1) Solution

1- type the folowing first

vue add @vue/cli-service

2- add following code to package.json if there were not

«scripts»: {
«serve»: «vue-cli-service serve»,
«build»: «vue-cli-service build»
},

3- type code ==> npm run serve <=== for serve or type==> npm run build for build <==

npm run serve 

or following to build

npm run build

if only doesnt work you just run following and reapeat again

npm install

npm init

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Not configured to listen on any interfaces dhcp ошибка
  • Not another pdf scanner 2 ошибка драйвера сканирования