0

最近我建立了一个 Laravel 项目,我尝试将它与 Vue.js 集成并使用命令行npm run watch查看结果,但它显示了一些错误。不仅如此,当我运行php artisan serve. php 编码工作正常,但 Vue 根本没有出现。

命令行:

C:\Users\PC19\Documents\Projects\laravelVueTry>npm run watch
    
    > Web@1.0.0 watch C:\Users\PC19\Documents\Projects\laravelVueTry
    > NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js
    
    'NODE_ENV' is not recognized as an internal or external command,
    operable program or batch file.
    npm ERR! code ELIFECYCLE
    npm ERR! errno 1
    npm ERR! Web@1.0.0 watch: `NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
    npm ERR! Exit status 1
    npm ERR!
    npm ERR! Failed at the Web@1.0.0 watch 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!     C:\Users\PC19\AppData\Roaming\npm-cache\_logs\2020-10-14T00_20_16_023Z-debug.log

调试日志:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Users\\PC19\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'run',
1 verbose cli   'watch'
1 verbose cli ]
2 info using npm@6.14.8
3 info using node@v13.9.0
4 verbose run-script [ 'prewatch', 'watch', 'postwatch' ]
5 info lifecycle Web@1.0.0~prewatch: Web@1.0.0
6 info lifecycle Web@1.0.0~watch: Web@1.0.0
7 verbose lifecycle Web@1.0.0~watch: unsafe-perm in lifecycle true
8 verbose lifecycle Web@1.0.0~watch: PATH: C:\Users\PC19\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\Users\PC19\Documents\Projects\laravelVueTry\node_modules\.bin;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\iis express\PHP\v7.1;C:\Program Files\PHP\v5.3;C:\Program Files\iis express\PHP\v7.2;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\iCLS\;C:\Program Files\Intel\Intel(R) Management Engine Components\iCLS\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Microsoft\Web Platform Installer\;C:\Users\PC19\AppData\Local\Microsoft\WindowsApps;C:\Program Files\nodejs\;";C:\Program Files (x86)\Git\bin;C:\Program Files (x86)\Git\cmd";C:\Program Files\Git\cmd;C:\Program Files\Java\jdk1.8.0_231\bin;C:\Program Files\Java\jre1.8.0_241\bin;C:\Users\PC19\AppData\Local\Android\Sdk\platform-tools;C:\Gradle\gradle-6.2\bin;C:\ProgramData\ComposerSetup\bin;C:\Users\PC19\AppData\Local\Microsoft\WindowsApps;C:\Users\PC19\AppData\Roaming\npm;C:\Users\PC19\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\PC19\AppData\Roaming\Composer\vendor\bin
9 verbose lifecycle Web@1.0.0~watch: CWD: C:\Users\PC19\Documents\Projects\laravelVueTry
10 silly lifecycle Web@1.0.0~watch: Args: [
10 silly lifecycle   '/d /s /c',
10 silly lifecycle   'NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js'
10 silly lifecycle ]
11 silly lifecycle Web@1.0.0~watch: Returned: code: 1  signal: null
12 info lifecycle Web@1.0.0~watch: Failed to exec watch script
13 verbose stack Error: Web@1.0.0 watch: `NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Users\PC19\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:321:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Users\PC19\AppData\Roaming\npm\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:321:20)
13 verbose stack     at maybeClose (internal/child_process.js:1026:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid Web@1.0.0
15 verbose cwd C:\Users\PC19\Documents\Projects\laravelVueTry
16 verbose Windows_NT 10.0.18363
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\PC19\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "run" "watch"
18 verbose node v13.9.0
19 verbose npm  v6.14.8
20 error code ELIFECYCLE
21 error errno 1
22 error Web@1.0.0 watch: `NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js`
22 error Exit status 1
23 error Failed at the Web@1.0.0 watch script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

包.json:

{
  "private": true,
  "scripts": {
    "dev": "NODE_ENV=development webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "watch": "NODE_ENV=development webpack --watch --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "hot": "NODE_ENV=development webpack-dev-server --inline --hot --config=node_modules/laravel-mix/setup/webpack.config.js",
    "production": "NODE_ENV=production webpack --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js",
    "build": "echo 'build script executed'"
  },
  "devDependencies": {
    "axios": "^0.16.2",
    "babel-loader": "^7.1.1",
    "bootstrap": "^4.0.0-beta",
    "cross-env": "^5.2.1",
    "css-loader": "^0.28.4",
    "file-loader": "^0.11.2",
    "jquery": "^3.1.1",
    "laravel-mix": "^1.2.0",
    "lodash": "^4.17.4",
    "popper.js": "^1.12.9",
    "postcss-loader": "^2.0.6",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.18.2",
    "vue": "^2.1.10",
    "vue-loader": "^13.0.1",
    "webpack": "^3.2.0"
  },
  "dependencies": {
    "mammoth": "^1.4.9"
  },
  "name": "Web",
  "description": "<p align=\"center\"><img src=\"https://laravel.com/assets/img/components/logo-laravel.svg\"></p>",
  "version": "1.0.0",
  "main": "gulpfile.js",
  "directories": {
    "test": "tests"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}

当我运行 npm install 时,除了一些警告之外,它没有显示任何可疑错误

C:\Users\PC19\Documents\Projects\laravelVueTry>npm install
npm WARN ajv-keywords@3.5.2 requires a peer of ajv@^6.9.1 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules\watchpack\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

audited 1498 packages in 5.574s

35 packages are looking for funding
  run `npm fund` for details

found 64 vulnerabilities (25 low, 17 moderate, 22 high)
  run `npm audit fix` to fix them, or `npm audit` for details  

我还尝试了一些来自谷歌的其他解决方案,比如使用命令

del package-lock.json
rd /s /q node_modules
npm cache clear --force
npm install

毕竟,它没有用。有人在这里检测到错误吗?提前致谢

4

0 回答 0