Bonjour,

Voila je rencontre un petit problème avec mon code.

Ce que je fais

Pour lancer mon serveur je fait cette ligne de commande :

npm run dev

Ce que je veux

Quand j'éxécute cette commande nodejs inicier un petit serveur de dévelopement.

Ce que j'obtiens

J'ai une erreur qui dit que nodejs n'est pas à jour :

@ dev /var/www/local.dev/lakamark
> gulp watch

sh: 1: gulp: not found

npm ERR! Linux 3.2.0-4-amd64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v5.1.0
npm ERR! npm  v3.3.12
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @ dev: `gulp watch`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the @ dev script 'gulp watch'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the  package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     gulp watch
npm ERR! You can get their info via:
npm ERR!     npm owner ls 
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/local.dev/lakamark/npm-debug.log

Je lance nodejs depuis une machine vagrant. Voici la configuration de nodejs que j'ai dans ma vm :

npm version
{ npm: '3.3.12',
  ares: '1.10.1-DEV',
  http_parser: '2.6.0',
  icu: '56.1',
  modules: '47',
  node: '5.1.0',
  openssl: '1.0.2d',
  uv: '1.7.5',
  v8: '4.6.85.31',
  zlib: '1.2.8' }

Merci de votre aide.

10 réponses


Bonjour.
Il te suffit de mettre npm et Node.js à jour, pour information :

The current stable version of npm is 3.10.3
Node.js : Current version: v4.4.7

et surtous d'installer gulp en global sur la machine virtuel pour gulp soit accessible en commande terminal

lakamark
Auteur

J'ais mis à jour nodejs et npm et l'erreur est toujours présente :

 sudo npm run dev

> comments@1.0.0 dev /var/www/local.dev/lakamark/front
> node build/dev-server.js

/var/www/local.dev/lakamark/front/node_modules/express/lib/router/index.js:143
  var protohost = fqdn ? req.url.

SyntaxError: Unexpected token ILLEGAL
    at exports.runInThisContext (vm.js:53:16)
    at Module._compile (module.js:373:25)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)
    at Module.require (module.js:353:17)
    at require (internal/module.js:12:17)
    at Object.<anonymous> (/var/www/local.dev/lakamark/front/node_modules/express/lib/application.js:17:14)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)

npm ERR! Linux 3.2.0-4-amd64
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "dev"
npm ERR! node v4.4.7
npm ERR! npm  v3.10.3
npm ERR! code ELIFECYCLE
npm ERR! comments@1.0.0 dev: `node build/dev-server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the comments@1.0.0 dev script 'node build/dev-server.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the comments package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node build/dev-server.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs comments
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls comments
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/local.dev/lakamark/front/npm-debug.log

{ comments: '1.0.0',
  npm: '3.10.3',
  ares: '1.10.1-DEV',
  http_parser: '2.5.2',
  icu: '56.1',
  modules: '46',
  node: '4.4.7',
  openssl: '1.0.2h',
  uv: '1.8.0',
  v8: '4.5.103.36',
  zlib: '1.2.8' }

fait voir ton package.json

lakamark
Auteur

@Defy voici le fichier json package.json de mon projet :

{
  "name": "comments",
  "version": "1.0.0",
  "description": "A Vue.js project",
  "author": "LakaMark <contact@lakamark.com>",
  "private": true,
  "scripts": {
    "dev": "node build/dev-server.js",
    "build": "node build/build.js",
    "unit": "karma start test/unit/karma.conf.js --single-run",
    "e2e": "node test/e2e/runner.js",
    "test": "npm run unit && npm run e2e",
    "lint": "eslint --ext .js,.vue src test/unit/specs test/e2e/specs"
  },
  "dependencies": {
    "vue": "^1.0.21",
    "babel-runtime": "^6.0.0"
  },
  "devDependencies": {
    "babel-core": "^6.0.0",
    "babel-loader": "^6.0.0",
    "babel-plugin-transform-runtime": "^6.0.0",
    "babel-preset-es2015": "^6.0.0",
    "babel-preset-stage-2": "^6.0.0",
    "connect-history-api-fallback": "^1.1.0",
    "css-loader": "^0.23.0",
    "eslint": "^2.10.2",
    "eslint-friendly-formatter": "^2.0.5",
    "eslint-loader": "^1.3.0",
    "eslint-plugin-html": "^1.3.0",
    "eslint-config-standard": "^5.1.0",
    "eslint-plugin-promise": "^1.0.8",
    "eslint-plugin-standard": "^1.3.2",
    "eventsource-polyfill": "^0.9.6",
    "express": "^4.13.3",
    "extract-text-webpack-plugin": "^1.0.1",
    "file-loader": "^0.8.4",
    "function-bind": "^1.0.2",
    "html-webpack-plugin": "^2.8.1",
    "http-proxy-middleware": "^0.12.0",
    "json-loader": "^0.5.4",
    "karma": "^0.13.15",
    "karma-coverage": "^0.5.5",
    "karma-mocha": "^0.2.2",
    "karma-phantomjs-launcher": "^1.0.0",
    "karma-sinon-chai": "^1.2.0",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-spec-reporter": "0.0.24",
    "karma-webpack": "^1.7.0",
    "lolex": "^1.4.0",
    "mocha": "^2.4.5",
    "chai": "^3.5.0",
    "sinon": "^1.17.3",
    "sinon-chai": "^2.8.0",
    "inject-loader": "^2.0.1",
    "isparta-loader": "^2.0.0",
    "phantomjs-prebuilt": "^2.1.3",
    "chromedriver": "^2.21.2",
    "cross-spawn": "^2.1.5",
    "nightwatch": "^0.8.18",
    "selenium-server": "2.53.0",
    "ora": "^0.2.0",
    "shelljs": "^0.6.0",
    "url-loader": "^0.5.7",
    "vue-hot-reload-api": "^1.2.0",
    "vue-html-loader": "^1.0.0",
    "vue-loader": "^8.3.0",
    "vue-style-loader": "^1.0.0",
    "webpack": "^1.12.2",
    "webpack-dev-middleware": "^1.4.0",
    "webpack-hot-middleware": "^2.6.0",
    "webpack-merge": "^0.8.3"
  }
}

J'ai utililisé ce générateur de template : https://github.com/vuejs/vue-cli

c'est deux commande lance quoi exactement?

"dev": "node build/dev-server.js",
"build": "node build/build.js",
lakamark
Auteur

La commande "dev" lance un petit serveur de developement nodejs et la commande "buid" execute ce script :

// https://github.com/shelljs/shelljs
require('shelljs/global')
env.NODE_ENV = 'production'

var path = require('path')
var config = require('../config')
var ora = require('ora')
var webpack = require('webpack')
var webpackConfig = require('./webpack.prod.conf')

console.log(
  '  Tip:\n' +
  '  Built files are meant to be served over an HTTP server.\n' +
  '  Opening index.html over file:// won\'t work.\n'
)

var spinner = ora('building for production...')
spinner.start()

var assetsPath = path.join(config.build.assetsRoot, config.build.assetsSubDirectory)
rm('-rf', assetsPath)
mkdir('-p', assetsPath)
cp('-R', 'static/', assetsPath)

webpack(webpackConfig, function (err, stats) {
  spinner.stop()
  if (err) throw err
  process.stdout.write(stats.toString({
    colors: true,
    modules: false,
    children: false,
    chunks: false,
    chunkModules: false
  }) + '\n')
})

Je pense qui lance aussi webpack.

tu as bien installer toute les dependances dans ton projet?

Est ce que tes dépendances sont à jour vis a vis de ton package.json ? Gulp aussi ?

lakamark
Auteur

comment on peut verifier si les dependance sont â jour? J'ai installer gulp et webpack globalement sur ma machine vertuel.