vuejs / vue-cli

🛠️ webpack-based tooling for Vue.js Development
https://cli.vuejs.org/
MIT License
29.76k stars 6.33k forks source link

Task Error [serve, build, lint] Ended with error code 1 #1726

Closed javidrashid closed 6 years ago

javidrashid commented 6 years ago

Version

3.0.0-rc.3

Reproduction link

http://no-url

Steps to reproduce

Install a node module say node-sass, sass-loader, Everything goes for a toss after that. and any command you run, build, serve or lint, The task fails with the message Task Error [serve, build, lint] Ended with error code 1

What is expected?

It should work.

What is actually happening?

The whole setup crashes and you can't even run the app if you start over.


I did some additional debugging and you see it reports missing of the core modules when it happens like;

$ vue-cli-service inspect --mode production module.js:549 throw err; ^

Error: Cannot find module 'request' at Function.Module._resolveFilename (module.js:547:15) at Function.Module._load (module.js:474:25) at Module.require (module.js:596:17) at require (internal/module.js:11:18) at /path/to/project/node_modules/request-promise-native/lib/rp.js:8:12 at module.exports (/path/to/project/node_modules/stealthy-require/lib/index.js:62:23) at Object. (/path/to/project/node_modules/request-promise-native/lib/rp.js:7:15) at Module._compile (module.js:652:30) at Object.Module._extensions..js (module.js:663:10) at Module.load (module.js:565:32)

LinusBorg commented 6 years ago

Hi!

Can you provide any more details? "Crate a project and install a npm package" is not enough. At least, I cannot reproduce this behaviour with those instructions.

you should be able to provide a repository with the changes that trigger the behaviour that you describe.

javidrashid commented 6 years ago

Did you try installing node-sass and sass-loader. I will see if I can create a sandbox environment to reproduce the issue. In the meantime I have added a couple of screenshots if that helps. I didn't had this issue if I install any other plugin/npm package, only with node-sass and sass-loader.

Screen Shot 1:

sc_1

Screen 2:

sc_2
LinusBorg commented 6 years ago

Oh, so this is about the UI? you didn't mention that at all ....

javidrashid commented 6 years ago

Yes but it would even break the command line setup too. I just added UI screenshots for more clarity.

LinusBorg commented 6 years ago

In that case, a sandbox would be apprechiated because I can't reproduce this so far.

SerbanC commented 6 years ago

Having trouble since today with this also. In my case, after wiping node_modules and running npm i, I get Error: Cannot find module 'request' on both npm run serve and npm run build.

If needed, I can try to reproduce in a repo.

Akryum commented 6 years ago

the instructions will currently install 2.9.6

No.

npm install -g @vue/cli
# OR
yarn global add @vue/cli

This installs @vue/cli which is 3.x. 2.x is vue-cli.

SerbanC commented 6 years ago

I created a fresh project using the CLI tool + the same saved Vue app config file and the app ran fine. Turned out it was my package-lock.json which was broken somehow, I can't figure out how. After replacing my package-lock.json with the one from the fresh project (then re-added all other deps and installed them too), everything seems to work fine again.

node version: 8.11.2 npm version: 6.1.0

contents of my package.json:

{
  "name": "[redacted]",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint",
    "test:unit": "vue-cli-service test:unit",
    "docs": "jsdoc -c ./jsdoc.config.json"
  },
  "dependencies": {
    "es6-promise": "^4.2.4",
    "vue": "^2.5.16",
    "vue-router": "^3.0.1",
    "vuex": "^3.0.1"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.0.0-beta.15",
    "@vue/cli-plugin-eslint": "^3.0.0-beta.15",
    "@vue/cli-plugin-unit-jest": "^3.0.0-beta.15",
    "@vue/cli-service": "^3.0.0-beta.15",
    "@vue/eslint-config-standard": "^3.0.0-rc.3",
    "@vue/test-utils": "^1.0.0-beta.16",
    "axios": "^0.18.0",
    "axios-mock-adapter": "^1.15.0",
    "babel-core": "7.0.0-bridge.0",
    "babel-jest": "^23.0.1",
    "jsdoc": "^3.5.5",
    "jsdoc-vuejs": "^2.0.1",
    "moment": "^2.22.2",
    "moment-timezone": "^0.5.20",
    "node-sass": "^4.9.0",
    "sass-loader": "^7.0.1",
    "vue-cli-plugin-webpack-bundle-analyzer": "^1.1.1",
    "vue-template-compiler": "^2.5.16"
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie < 8"
  ]
}
revelt commented 6 years ago

@javidrashid please update, did you had any luck solving this yet considering the given advice above to wipe package-lock and reinstall. @javidrashid I can't stop wondering, what is the reason to install node-sass and sass-loader at the first place? CLI offers SASS boilerplate automatically:

sass

Akryum commented 6 years ago

So it seems it was an issue with your local dev environment. Closing until a reliable way to reproduce is found.

javidrashid commented 6 years ago

@revelt : Apologies for the delay, I had already wiped out my client_side code before I could try the instructions of updating package-lock so can't confirm if that solves the issue. That said, I tried reproducing it again and no luck so @Akryum it is good to close for now.

revelt commented 6 years ago

good stuff!

coolemur commented 6 years ago

I have the same issue on my projects with vue ui.

  1. Create project.
  2. npm install sass-loader --save-dev
  3. npm install --save-dev node-sass
  4. vue ui task - serve

Result:

Task ... :serve ended with error code 1

revelt commented 6 years ago

@coolemur are you aware Vue CLI comes with SASS already pre-wired? https://github.com/vuejs/vue-cli/issues/1726#issuecomment-402615919 — I wonder why do you install sass-loader and node-sass?

If you select "Manually select features" > "CSS Preprocessors" you'll get SASS wired up automatically for you...

coolemur commented 6 years ago

@revelt

When I try to use

<style lang="scss" scoped>

</style>

in my vue ui projects, error 'Can't resolve 'sass-loader'' appears. So I assume Vue ui doesn't come with sass pre-wired.

revelt commented 6 years ago

@coolemur OK, strange. Did you select "Manually select features" > "CSS Preprocessors" in the wizard during init stage?

I set up a blank project yesterday and hacked all evening and today morning in SASS, no problems.

coolemur commented 6 years ago

@revelt Sorry. I missed a point that I need to Manually select it. Now it works just fine. Thank you.

revelt commented 6 years ago

@coolemur no probs happy to help