zcdll

1013 经验值

视频里面 passport.devpassport-client.dev 分别访问两个 Laravel 项目是怎么做到的呀?能稍微详细说一下吗?

问题解决了,我把 npm 降级到 v5.1.0,把 package.lock.json 删除,把 package.json 更新到 github.com 最新版,再重新 npm install 就好了。
我又重新创建工程试了下,用 npm v5.1.0 是没有问题的,只是因为网络的原因可能。。。

我在 Github 上的 laravel-mix 提了 issue,JefferyWay 说是因为 npm v5.2.0 的 bug,已经修复了但还没有 release。

npm run dev errors on Ubuntu 16.04

谢谢 Jerry!

我刚才把 laravel Github 的地址 clone 下来试了一遍,还是不行。。。报第一次的错误。。

zcdll@zcdll-Infisa:~/Coder/test/php/laravel-git$ npm run dev

> @ dev /home/zcdll/Coder/test/php/laravel-git
> npm run development


> @ development /home/zcdll/Coder/test/php/laravel-git
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting                                                                      

 ERROR  Failed to compile with 2 errors                                                                                  20:12:12

These dependencies were not found:

* /home/zcdll/Coder/test/php/laravel-git/resources/assets/sass/app.scss in multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss
* /home/zcdll/Coder/test/php/laravel-git/resources/assets/js/app.js in multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

To install them, you can run: npm install --save /home/zcdll/Coder/test/php/laravel-git/resources/assets/sass/app.scss /home/zcdll/Coder/test/php/laravel-git/resources/assets/js/app.js
     Asset    Size  Chunks             Chunk Names
/js/app.js  2.8 kB       0  [emitted]  /js/app
npm ERR! code ELIFECYCLE
npm ERR! errno 2
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! Exit status 2
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/zcdll/.npm/_logs/2017-07-12T12_12_13_257Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 2
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/zcdll/.npm/_logs/2017-07-12T12_12_13_291Z-debug.log

我把 laravel-mix 升级到 v1.2.0 之后,运行 npm run dev 报新的错误了。。

zcdll@zcdll-Infisa:~/Coder/test/php/laravel-5.4.23$ npm run dev

> @ dev /home/zcdll/Coder/test/php/laravel-5.4.23
> npm run development


> @ development /home/zcdll/Coder/test/php/laravel-5.4.23
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

events.js:163
      throw er; // Unhandled 'error' event
      ^

Error: spawn node_modules/webpack/bin/webpack.js ENOENT
    at exports._errnoException (util.js:1050:11)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:193:32)
    at onErrorNT (internal/child_process.js:367:16)
    at _combinedTickCallback (internal/process/next_tick.js:80:11)
    at process._tickCallback (internal/process/next_tick.js:104:9)
    at Module.runMain (module.js:607:11)
    at run (bootstrap_node.js:427:7)
    at startup (bootstrap_node.js:151:9)
    at bootstrap_node.js:542:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
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! Exit status 1
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/zcdll/.npm/_logs/2017-07-12T11_55_06_890Z-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/zcdll/.npm/_logs/2017-07-12T11_55_06_921Z-debug.log
{
  "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": "cross-env 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": "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 --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js"
  },
  "devDependencies": {
    "axios": "^0.15.3",
    "bootstrap-sass": "^3.3.7",
    "cross-env": "^3.2.3",
    "jquery": "^3.1.1",
    "laravel-mix": "0.*",
    "lodash": "^4.17.4",
    "vue": "^2.1.10"
  }
}

我的 package.json

zcdll@zcdll-Infisa:~/Coder/test/php/laravel-5.4.23$ npm ls laravel-mix
/home/zcdll/Coder/test/php/laravel-5.4.23
└── [email protected] 

检查了下,上条评论中,报错的两个文件都存在的。那两个文件是 Laravel 自带的文件就是 app.js 和 app.scss

是本地的 Ubuntu,还没有在服务器上尝试。我刚才把 node 升级到 v7.10.1,清空了 node_modules,加了代理重新 npm install 成功。运行 npm run dev 还是报同样的错误。。

上面的 log 文件内容如下:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'development' ]
2 info using [email protected]
3 info using [email protected]
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/local/lib/node_modules/npm/bin/node-gyp-bin:/home/zcdll/Coder/test/php/laravel-5.4.23/node_modules/.bin:/usr/local/lib/node_modules/npm/bin/node-gyp-bin:/home/zcdll/Coder/test/php/laravel-5.4.23/node_modules/.bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/local/go/bin
9 verbose lifecycle @~development: CWD: /home/zcdll/Coder/test/php/laravel-5.4.23
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 silly lifecycle @~development: Returned: code: 2  signal: null
12 info lifecycle @~development: Failed to exec development script
13 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`
13 verbose stack Exit status 2
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:289:16)
13 verbose stack     at emitTwo (events.js:106:13)
13 verbose stack     at EventEmitter.emit (events.js:191:7)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
13 verbose stack     at emitTwo (events.js:106:13)
13 verbose stack     at ChildProcess.emit (events.js:191:7)
13 verbose stack     at maybeClose (internal/child_process.js:891:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
14 verbose pkgid @
15 verbose cwd /home/zcdll/Coder/test/php/laravel-5.4.23
16 verbose Linux 4.4.0-83-generic
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "development"
18 verbose node v6.11.0
19 verbose npm  v5.2.0
20 error code ELIFECYCLE
21 error errno 2
22 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`
22 error Exit status 2
23 error Failed at the @ development script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]

我在 Ubuntu 16.04, Laravel 5.4, node 6.11.0, npm 5.2.0, PHP 7.1 下,用 github.com 上 Laravel 的源码包,或者 通过 composer create 方式 创建项目,都试了,在 composer install 时没有问题,Laravel 正常跑起来了。执行 npm install 时网络错误,node-sass 没下下来,我加代理后下下来了。又执行了一遍 npm install 没有错误。但是在执行 npm run dev时报错如下,尝试了好几遍都不行。。。也查了了好多资料,看了 JeffreyWay 在 Github 和 Laracasts 的回答都没有解决问题。。。希望 Jelly 帮我看看这个问题!

zcdll@zcdll-Infisa:~/Coder/test/php/laravel-5.4.23$ npm run dev

> @ dev /home/zcdll/Coder/test/php/laravel-5.4.23
> npm run development


> @ development /home/zcdll/Coder/test/php/laravel-5.4.23
> cross-env NODE_ENV=development node_modules/webpack/bin/webpack.js --progress --hide-modules --config=node_modules/laravel-mix/setup/webpack.config.js

 95% emitting                                                                      

 ERROR  Failed to compile with 2 errors                                                                                  15:49:23

These dependencies were not found:

* /home/zcdll/Coder/test/php/laravel-5.4.23/resources/assets/js/app.js in multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss
* /home/zcdll/Coder/test/php/laravel-5.4.23/resources/assets/sass/app.scss in multi ./resources/assets/js/app.js ./resources/assets/sass/app.scss

To install them, you can run: npm install --save /home/zcdll/Coder/test/php/laravel-5.4.23/resources/assets/js/app.js /home/zcdll/Coder/test/php/laravel-5.4.23/resources/assets/sass/app.scss
            Asset      Size  Chunks             Chunk Names
       /js/app.js   2.96 kB       0  [emitted]  /js/app
mix-manifest.json  32 bytes          [emitted]  
npm ERR! code ELIFECYCLE
npm ERR! errno 2
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! Exit status 2
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/zcdll/.npm/_logs/2017-07-12T07_49_23_869Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! @ dev: `npm run development`
npm ERR! Exit status 2
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/zcdll/.npm/_logs/2017-07-12T07_49_23_910Z-debug.log

视频加速一定要加上啊。。。另外好多东西目测都还是原来 laravist.com 的地址,换域名目测工作量很大,加油啊!