我的laravel 5.6运行npm命令的下一个错误输出带有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"
}
}
你能否提出一些可能会引发错误以及如何修复错误的提示?
配置文件中有些错误或什么?
非常感谢!
答案 0 :(得分:9)
您需要安装cross-env
npm包。
npm install --save-dev cross-env
它已在您的dev依赖项中列出,请务必先运行npm install
。
答案 1 :(得分:1)
就我而言,我必须将 node 升级到版本 14。
使用
检查您的节点版本node -v
然后,从 NODESOURCE
安装一个稳定版本基本上,
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
在此之后,
npm install
根据您的需要遵循命令。 就我而言:
npm run dev
如果您仍然遇到问题,请尝试NPM ERROR
仅列出此错误的其他关键字:
<块引用>npm 错误! @发展:mix
laravel npm ERR!代码ELIFECYCLE laravel
错误代码 ELIFECYCLE
npm 错误! @ 开发脚本失败 呃!代码 EACCES
错误!代码生命周期
错误!代码 EMISSINGARG
答案 2 :(得分:0)
即使我使用了与以前使用的相同的最新版本的 npm,也得到了上述内容 执行 npm run dev 命令时出错。部分错误的详细信息是“npm ERR!@development:mix laravel npm ERR!code ELIFECYCLE laravel 错误代码 ELIFECYCLE mix 未识别为内部命令 npm ERR!在@development script ERR!code EACCESerrors 处失败”
对我有用的解决方案:我已经卸载了全局安装的 npm,并在全局重新安装了相同的 npm,并且“npm run dev”运行良好。感谢您强调该问题与 npm 或不兼容的 npm 版本有关。