我在运行npm命令时,针对我的Laravel 5.6与Bootstrap项目出现了以下错误输出:
$ npm run dev
> @ dev /mnt/_work_sdb8/wwwroot/lar/B4test
> npm run development
> @ development /mnt/_work_sdb8/wwwroot/lar/B4test
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
sh: 1: cross-env: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the @ development script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/serge/.npm/_logs/2018-04-25T10_54_37_776Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the @ dev script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/serge/.npm/_logs/2018-04-25T10_54_37_794Z-debug.log
文件 /home/serge/.npm/_logs/2018-04-25T10_54_37_776Z-debug.log 包含如下内容:
0 info it worked if it ends with ok
1 verbose cli [ '/usr/bin/node', '/usr/bin/npm', 'run', 'development' ]
2 info using npm@6.0.0
3 info using node@v9.11.1
4 verbose run-script [ 'predevelopment', 'development', 'postdevelopment' ]
5 info lifecycle @~predevelopment: @
6 info lifecycle @~development: @
7 verbose lifecycle @~development: unsafe-perm in lifecycle true
8 verbose lifecycle @~development: PATH: /usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/mnt/_work_sdb8/wwwroot/lar/B4test/node_modules/.bin:/usr/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/mnt/_work_sdb8/wwwroot/lar/B4test/node_modules/.bin:/home/serge/.composer/vendor/bin:/home/serge/.composer/vendor/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:~/.composer/vendor/bin
9 verbose lifecycle @~development: CWD: /mnt/_work_sdb8/wwwroot/lar/B4test
10 silly lifecycle @~development: Args: [ '-c',
10 silly lifecycle 'cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js' ]
11 info lifecycle @~development: Failed to exec development script
12 verbose stack Error: @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
12 verbose stack spawn ENOENT
12 verbose stack at ChildProcess.<anonymous> (/usr/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:48:18)
12 verbose stack at ChildProcess.emit (events.js:180:13)
12 verbose stack at maybeClose (internal/child_process.js:936:16)
12 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:220:5)
13 verbose pkgid @
14 verbose cwd /mnt/_work_sdb8/wwwroot/lar/B4test
15 verbose Linux 4.13.0-38-generic
16 verbose argv "/usr/bin/node" "/usr/bin/npm" "run" "development"
17 verbose node v9.11.1
18 verbose npm v6.0.0
19 error file sh
20 error code ELIFECYCLE
21 error errno ENOENT
22 error syscall spawn
23 error @ development: `cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
23 error spawn ENOENT
24 error Failed at the @ development script.
24 error This is probably not a problem with npm. There is likely additional logging output above.
25 verbose exit [ 1, true ]
在composer.json文件中:{
"name": "laravel/laravel",
"description": "The Laravel Framework.",
"keywords": ["framework", "laravel"],
"license": "MIT",
"type": "project",
"require": {
"php": "^7.1.3",
"fideloper/proxy": "^4.0",
"laravel/framework": "5.6.*",
"components/highlightjs": "^9.12",
"doctrine/dbal": "^2.6",
"intervention/image": "^2.4",
"laracasts/utilities": "^3.0",
"laravel/tinker": "~1.0",
"nwidart/laravel-modules": "^3.0",
"pusher/pusher-php-server": "^3.0",
"spatie/laravel-backup": "^5.1",
"wboyz/laravel-enum": "^0.2.1"
},
"require-dev": {
"filp/whoops": "^2.0",
"fzaninotto/faker": "^1.7",
"mockery/mockery": "^1.0",
"nunomaduro/collision": "^2.0",
"phpunit/phpunit": "^7.0",
"barryvdh/laravel-debugbar": "^3.1",
"laravel/dusk": "~3.0"
},
"autoload": {
"classmap": [
"database/seeds",
"database/factories"
],
"psr-4": {
"App\\": "app/",
"Modules\\": "Modules/"
}
},
"autoload-dev": {
"psr-4": {
"Tests\\": "tests/"
}
},
"extra": {
"laravel": {
"dont-discover": [
]
}
},
"scripts": {
"post-root-package-install": [
"@php -r \"file_exists('.env') || copy('.env.example', '.env');\""
],
"post-create-project-cmd": [
"@php artisan key:generate"
],
"post-autoload-dump": [
"Illuminate\\Foundation\\ComposerScripts::postAutoloadDump",
"@php artisan package:discover"
]
},
"config": {
"preferred-install": "dist",
"sort-packages": true,
"optimize-autoloader": true
},
"minimum-stability": "dev",
"prefer-stable": true
}
在 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",
"popper.js": "^1.12",
"cross-env": "^5.1",
"jquery": "^3.2",
"laravel-mix": "^2.0",
"lodash": "^4.17.4",
"vue": "^2.5.7",
"vue-template-compiler": "^2.5.16",
"vue2-collapse": "^1.0.11"
},
"dependencies": {
"element-ui": "^2.3.6",
"font-awesome": "^4.7.0",
"fullcalendar": "^3.9.0",
"highlight.js": "^9.12.0",
"laravel-echo": "^1.3.5",
"marked": "^0.3.19",
"pusher-js": "^4.2.2",
"v-toaster": "^1.0.3",
"vee-validate": "^2.0.6",
"vee-validate-laravel": "^1.0.1",
"vue-bootstrap-datetimepicker": "^4.1.3",
"vue-chat-scroll": "^1.2.1",
"vue-fullcalendar": "^1.0.9",
"vue-js-popover": "^1.1.7",
"vue-moment": "^3.2.0",
"vue-mouse-menu": "^1.1.0",
"vue-nl2br": "0.0.5",
"vue-notify-me": "^1.1.0",
"vue-popperjs": "^1.2.6",
"vue-router": "^3.0.1",
"vue-select": "^2.4.0",
"vue-simple-calendar": "^2.2.0",
"vue-timeago": "^3.4.4",
"vuejs-datepicker": "^0.9.29"
}
}
你能给一个提示,是什么导致了错误并怎样修复它?
是配置文件中的某些错误吗?
非常感谢!