Gregor Voinov
Gregor Voinov

Reputation: 2263

After installing app as npm package, “vue-cli-service” not found

I have a package that is a vuejs application. If I install it local to my project with "npm i 'path/to/app-vuejs --save-dev'" and then run

npm explore app-vuejs -- npm run serve

everything works. Server gets startet and I can view the generated pages. But after publishing on npm, installing it with 'npm i app-vuejs --save-dev' and run the command again I get the error

sh: vue-cli-service: command not found

I have now seen that the node-modules directory is different than in my local version... I tried to find the vue-cli-service and saw that I have many more folders in my local version than in my installed by npm

local installation:
local folder structure

installation from npm with less dependencies and no vue-cli:
install from npm

What need I to do that all node-modules including "cli-services" get installed?

this is my folder structure

- main-project
  - node_modules
    - helper-app-vuejs

Upvotes: 5

Views: 6462

Answers (3)

tjarbo
tjarbo

Reputation: 946

TL;DR: Move the @vue/cli-service at package.json from the devDependencies section to dependencies

The vue-cli-service is by default a devDependency and will not be part of the published version on npm, because devDependencies are only needed for development of this package. If you install your npm-package with npm i xxxx -save-dev, only the dependencies will be installed, because by definition these dependencies are needed at runtime. If you move the @vue/cli-service package to the dependencies section at package.json it will be ready at runtime of your other package.

Upvotes: 4

jacorl
jacorl

Reputation: 552

It is perfectly normal by my side. When you run : npm install on local enviroment you are gonna install both devDependencies and prodDependencies (Dependencies). When you install from npm public artifactory you are gonna use npm install --prod

When you publish an artifact you only allow to enduser to install prodDependencies, so not your devDependencies (missing vue-cli-service). Hope can be usefull

Upvotes: 0

Filip Huhta
Filip Huhta

Reputation: 2388

Sometimes it's just something that went wrong with node_modules when installing, have you tried: rm -rf node_modules and npm install?

If it doesn't work have a look at this: vue-cli-service: command not found

Upvotes: 3

Related Questions