Laravel版本:5.4.1 PHP版本:5.6 节点v8.9.3 npm v5.5.1 描述: npm命令在Windows上完全被破坏(在这种情况下是Windows 7),每当我运行npm run dev时,我都会收到以下错误:
'node_modules'未被识别为内部或外部命令, 可操作程序或批处理文件。
我的package.json
{
"private": true,
"scripts": {
"dev": "npm run development",
"development": "NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch": "NODE_ENV=development node_modules/webpack/bin/webpack.js --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
"watch-poll": "npm run watch -- --watch-poll",
"hot": "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": "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.16.2",
"bootstrap-sass": "^3.3.7",
"cross-env": "^5.0.1",
"jquery": "^3.1.1",
"laravel-mix": "^1.0",
"lodash": "^4.17.4",
"vue": "^2.1.10"
},
"dependencies": {
"laravel-echo": "^1.3.3",
"pusher-js": "^4.2.2"
}
}
并显示错误
> @ dev c:\wamp\www\web
> node node_modules/cross-env/bin/cross-env.js NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.co
nfig.js
path.js:7
throw new TypeError('Path must be a string. Received ' + inspect(path));
^
TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.parse (path.js:950:5)
at new File (c:\wamp\www\web\node_modules\laravel-mix\src\File.js:14:30)
at Object.module.exports.preprocess (c:\wamp\www\web\node_modules\laravel-mix\src\index.js:108:14)
at Object.module.exports.sass (c:\wamp\www\web\node_modules\laravel-mix\src\index.js:84:27)
at Object.<anonymous> (c:\wamp\www\web\webpack.mix.js:17:5)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Mix.initialize (c:\wamp\www\flores\node_modules\laravel-mix\src\Mix.js:38:9)
at Object.<anonymous> (c:\wamp\www\flores\node_modules\laravel-mix\setup\webpack.config.js:18:5)
at Module._compile (module.js:570:32)
我已经搜索或花了更多时间,但如果有任何人有想法,请不要成功,请事先知道谢谢
答案 0 :(得分:0)
使用转义双引号将您脚本中的所有路径引用括起来,即\”path/to/something.js\”
例如:
...
"scripts": {
...
"development": "NODE_ENV=development \”node_modules/webpack/bin/webpack.js\” --progress --hide-modules --config=\”node_modules/laravel-mix/setup/webpack.config.js\”",
...
},
...