运行" npm run dev"运行时的跨环境问题为了vue-cli

时间:2017-06-09 09:15:44

标签: node.js linux webpack centos vue.js

我安装在VirtualBox上的Centos7(真正的操作系统:Windows 7)。

  • 节点版本:6.10.3
  • Npm版本:3.10.10

我安装了vue-cli,就像这样:

sudo npm install -g vue-cli

然后我创建了一个新的vue项目,如下所示:

sudo vue init webpack-simple mynewproject

但是在运行" npm run dev":

时出现错误
> mynewproject@1.0.0 dev /var/www/html/mynewproject
> cross-env NODE_ENV=development webpack-dev-server --open --hot

sh: cross-env : commande introuvable

npm ERR! Linux 3.10.0-514.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "dev"
npm ERR! node v6.10.3
npm ERR! npm  v3.10.10
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! vuetest@1.0.0 dev: `cross-env NODE_ENV=development webpack-dev-server --open --hot`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the mynewproject@1.0.0 dev script 'cross-env NODE_ENV=development webpack-dev-server --open --hot'.
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 vuetest package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     cross-env NODE_ENV=development webpack-dev-server --open --hot
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs vuetest
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls vuetest
npm ERR! There is likely additional logging output above.

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

有谁知道如何修复它?

1 个答案:

答案 0 :(得分:3)

您需要/** * Starts Grizzly HTTP server exposing JAX-RS resources defined in this application. * @return Grizzly HTTP server. */ public static HttpServer startServer() { // create a resource config that scans for JAX-RS resources and providers // in com.example.rest package final ResourceConfig rc = new SampleAdminApplication(); // create and start a new instance of grizzly http server // exposing the Jersey application at BASE_URI HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(URI.create(BASE_URI)); WebappContext context = new WebappContext("WebappContext", "/" + webapp); context.addListener("com.vilabs.sample.sampleadmin.server.servlet.SampleAdminListener"); context.addFilter("SampleAdminFilter", SampleAdminFilter.class); context.addFilter("SampleAdminCsrfFilter", SampleAdminCsrfFilter.class); ServletRegistration registration = context.addServlet("ServletContainer", new ServletContainer(rc)); registration.addMapping("/*"); context.deploy(httpServer); return httpServer; } 到项目目录并运行:

cd

您可以在webpack-simple github repo

上找到相关说明