Laravel 5.4混合npm run dev错误

时间:2017-03-21 00:08:08

标签: laravel npm mix

所以我有一个laravel 5.4项目,当我运行npm install dev时,我收到以下错误

  

dev:node node_modules / cross-env / dist / bin / cross-env.js NODE_ENV = development node_modules / webpack / bin / webpack.js --progress --hide-modules --config = node_modules / laravel-mix /安装/ webpack.config.js`

这是我的package.json

{
    "private": true,
    "scripts": {
        "dev": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",

        "watch": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
        "watch-poll": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --watch-poll --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",

        "hot": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
        "production": "node node_modules/cross-env/dist/bin/cross-env.js NODE_ENV=production node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
    },

    "devDependencies": {
        "axios": "^0.15.3",
        "bootstrap-sass": "^3.3.7",
        "jquery": "^3.1.1",
        "laravel-elixir-webpack-react": "^1.0.1",
        "laravel-mix": "^0.8.1",
        "lodash": "^4.17.4",
        "react": "^15.4.2",
        "react-dom": "^15.4.2",
        "vue": "^2.1.10"
    }
}

为什么我会收到此错误?

3 个答案:

答案 0 :(得分:0)

运行此命令:

npm install --global cross-env

并在“devDependencies”

下的package.josn中添加"gulp": "^3.9.1"

这可能对您有所帮助

答案 1 :(得分:0)

我有相同的问题,并且您将其替换为package.json

{
"private": true,
"scripts": {
    "dev": "npm run development",
    "development": "cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "npm run development -- --watch",
    "watch-poll": "npm run watch -- --watch-poll",
    "hot": "cross-env NODE_ENV=development node_modules/webpack-dev-server/bin/webpack-dev-server.js --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "prod": "npm run production",
    "production": "cross-env NODE_ENV=production node_modules/webpack/bin/webpack.js --no-progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
},
"devDependencies": {
    "axios": "^0.18",
    "bootstrap": "^4.0.0",
    "jquery": "^3.2",
    "laravel-mix": "^2.0",
    "lodash": "^4.17.5",
    "popper.js": "^1.12",
    "vue": "^2.5.7",
    "autoprefixer": "^7.1.2",
    "babel-core": "^6.26.3",
    "babel-eslint": "^7.1.1",
    "babel-loader": "^7.1.1",
    "babel-plugin-component": "^1.1.0",
    "babel-plugin-istanbul": "^4.1.1",
    "babel-plugin-transform-runtime": "^6.22.0",
    "babel-preset-env": "^1.6.0",
    "babel-polyfill": "^6.26.0",
    "babel-preset-stage-2": "^6.22.0",
    "babel-register": "^6.22.0",
    "chai": "^4.1.2",
    "chalk": "^2.0.1",
    "chromedriver": "^2.27.2",
    "compression-webpack-plugin": "^1.0.1",
    "connect-history-api-fallback": "^1.3.0",
    "copy-webpack-plugin": "^4.1.0",
    "cross-env": "^5.0.1",
    "cross-spawn": "^5.0.1",
    "css-loader": "^0.28.0",
    "eslint": "^3.19.0",
    "eslint-config-standard": "^10.2.1",
    "eslint-friendly-formatter": "^3.0.0",
    "eslint-loader": "^1.7.1",
    "eslint-plugin-html": "^3.0.0",
    "eslint-plugin-import": "^2.6.1",
    "eslint-plugin-node": "^4.2.2",
    "eslint-plugin-promise": "^3.5.0",
    "eslint-plugin-standard": "^3.0.1",
    "eventsource-polyfill": "^0.9.6",
    "express": "^4.14.1",
    "extract-text-webpack-plugin": "^2.0.0",
    "file-loader": "^0.11.1",
    "friendly-errors-webpack-plugin": "^1.1.3",
    "function-bind": "^1.1.0",
    "html-webpack-plugin": "^2.28.0",
    "http-proxy-middleware": "^0.17.3",
    "inject-loader": "^3.0.0",
    "karma": "^1.4.1",
    "karma-coverage": "^1.1.1",
    "karma-mocha": "^1.3.0",
    "karma-phantomjs-launcher": "^1.0.2",
    "karma-phantomjs-shim": "^1.4.0",
    "karma-sinon-chai": "^1.3.1",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-spec-reporter": "0.0.31",
    "karma-webpack": "^2.0.2",
    "lolex": "^1.5.2",
    "marked": "^0.3.6",
    "mocha": "^3.2.0",
    "nightwatch": "^0.9.12",
    "node-sass": "^4.5.3",
    "opn": "^5.1.0",
    "optimize-css-assets-webpack-plugin": "^3.2.0",
    "ora": "^1.2.0",
    "phantomjs-prebuilt": "^2.1.14",
    "raw-loader": "^0.5.1",
    "sass-loader": "^5.0.1",
    "selenium-server": "^3.0.1",
    "semver": "^5.3.0",
    "shelljs": "^0.7.6",
    "sinon": "^2.1.0",
    "sinon-chai": "^2.8.0",
    "url-loader": "^0.5.8",
    "vue-loader": "^13.0.4",
    "vue-style-loader": "^3.0.1",
    "vue-template-compiler": "^2.5.2",
    "vue-test-utils": "^1.0.0-beta.3",
    "webpack": "^3.2.0",
    "webpack-bundle-analyzer": "^2.2.1",
    "webpack-dev-middleware": "^1.10.0",
    "webpack-hot-middleware": "^2.18.0",
    "webpack-merge": "^4.1.0"
},
"dependencies": {
    "chartist": "^0.11.0",
    "easy-pie-chart": "^2.1.7",
    "element-ui": "^2.0.3",
    "fullcalendar": "^3.6.2",
    "google-maps": "^3.2.1",
    "jquery": "^3.2.1",
    "jvectormap-next": "^3.0.0",
    "perfect-scrollbar": "0.7.1",
    "sweetalert2": "^6.11.4",
    "vee-validate": "^2.0.0-rc.21",
    "vue": "^2.5.2",
    "vue-clickaway": "^2.1.0",
    "vue-form-wizard": "^0.7.0",
    "vue-nav-tabs": "^0.5.4",
    "vue-notifyjs": "^0.2.0",
    "vue-router": "^3.0.1"
},
"engines": {
    "node": ">= 4.0.0",
    "npm": ">= 3.0.0"
}

之后,我做这个事情:

rm -rf node_modules
rm package-lock.json yarn.lock
npm cache clear --force
npm install 
npm run dev 

希望这对您有所帮助。

答案 2 :(得分:-1)

因为您正在尝试安装依赖项。

安装devDependencies,你可以做

npm install --only=dev

要运行dev,你可以

npm run dev