运行gulp给出“path.js:7 throw new TypeError('Path must be a string。Received'+ inspect(path)); [英] Running gulp gives "path.js:7 throw new TypeError('Path must be a string. Received ' + inspect(path));"

查看:2284
本文介绍了运行gulp给出“path.js:7 throw new TypeError('Path must be a string。Received'+ inspect(path));的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的Wordpress项目中,我使用 Laravel Elixir 处理资产。一切工作到今天。



现在每次运行 gulp 我都会收到:

  $ gulp 
path.js:7
throw new TypeError('Path must be a string。Received'+ inspect(路径));
^

TypeError:路径必须是字符串。收到{includePaths:
['bower_components / foundation-sites / scss /',
'bower_components / slick-carousel / slick']}
at assertPath(path.js:7:11)
在Object.join(path.js:1211:7)
在prefixOne(/ Users / slick / Code / Komarnicki2 / wp-content / themes / komarnicki / node_modules / laravel-elixir / dist / tasks /GulpPaths.js:143:43)在GulpPaths.prefix
(/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/laravel-elixir/dist/tasks/GulpPaths.js:153 :20)
在GulpPaths.src(/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/laravel-elixir/dist/tasks/GulpPaths.js:44:25)
at getPaths(/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/laravel-elixir/dist/tasks/recipes/sass.js:33:33)
at Function。<匿名> (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/laravel-elixir/dist/tasks/recipes/sass.js:21:33)
at Function。< anonymous> (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/laravel-elixir/dist/bootstrap/EnableExtension.js:16:18)
at / Users / slick / Code / Komarnicki2 / wp-content / themes / komarnicki / gulpfile.js:7:9
位于global.Elixir(/ Users / slick / Code / Komarnicki2 / wp-content / themes / komarnicki / node_modules / laravel-elixir / dist / index .js:21:5)

p>

我认为我的 node_modules 目录可能有问题,所以我做了 rm - 像往常一样,rf node_modules ,然后 npm install 。一切都被拉了,但最后我看到:


 ├──UNMET PEER依赖stream-browserify @ * 




它不喜欢来自 includePaths 的数组?我可以寻求一些帮助吗?谢谢。



编辑:



这是我的package.json:

  {
name:slick,
version:1.0.0,
devDependencies :{
gulp:^ 3.9.1,
laravel-elixir:^ 6.0.0-2
}
}


解决方案

这个解决方案帮助了我: https://stackoverflow.com/a/40047852/4197938


问题是选项已从第三个移动到
第四个参数。

所以我简单地添加了额外的 null includePaths 之前。


混合.sass('app.scss',null,null< - 这是解决方案,{b / b>

然后运行 gulp 给了

  $ gulp 
[13:15:29]使用gulpfile 〜/代码/ Komarnicki2 /可湿性粉剂内容/主题/ komarn icki / gulpfile.js
[13:15:29]开始'all'...
[13:15:29]开始'sass'...
[13:15: 29]'sass'60 ms后出错
[13:15:29]错误:缺少绑定/ Users / slick / Code / Komarnicki2 / wp-content / themes / komarnicki / node_modules / node-sass / vendor / darwin -x64-51 / binding.node
节点Sass无法为当前环境找到绑定:OS X 64位和Node.js 7.x

找到以下环境的绑定:
- 带有Node.js的OS X 64位6.x

这通常是因为您的环境在运行`npm install`后发生了变化。
运行`npm rebuild node-sass`为您当前的环境构建绑定。
在Object。< anonymous> (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/node-sass/lib/index.js:15:11)
at Module._compile(module.js:573:32 )
at Object.Module._extensions..js(module.js:582:10)
at Module.load(module.js:490:32)
at tryModuleLoad(module.js (module.js:441:3)
at Module.require(module.js:500:17)
at require(internal / module.js:20:19)
在Object。< anonymous> (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/gulp-sass/index.js:187:21)
在Module._compile(module.js:573:32)
[13:15:29]'all'在63 ms后出错
[13:15:29]插件'run-sequence(sass)'中的错误
消息:
缺少绑定/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/node-sass/vendor/darwin-x64-51/binding.node
节点Sass找不到您当前环境的绑定:带有Node.js的OS X 64位7.x

找到以下环境的绑定:
- 带Node.js的OS X 64位6.x

这通常是因为您的环境在运行`npm install`后发生了变化。
运行`npm rebuild node-sass`为您当前的环境构建绑定。
堆栈:
错误:缺少绑定/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/node-sass/vendor/darwin-x64-51/binding.node
节点Sass无法为您当前的环境找到绑定:OS X 64位和Node.js 7.x

找到以下环境的绑定:
- OS X 64- Node.js 6.x

这通常是因为你的环境在运行`npm install`后发生了变化。
运行`npm rebuild node-sass`为您当前的环境构建绑定。
在Object。< anonymous> (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/node-sass/lib/index.js:15:11)
at Module._compile(module.js:573:32 )
at Object.Module._extensions..js(module.js:582:10)
at Module.load(module.js:490:32)
at tryModuleLoad(module.js (module.js:441:3)
at Module.require(module.js:500:17)
at require(internal / module.js:20:19)
在Object。< anonymous> (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/gulp-sass/index.js:187:21)
在Module._compile(module.js:573:32)

然后我完成了输出中写的内容

npm重建node-sass



和finally gulp 做了工作

  $ gulp 
[13:20:18]使用gulpfile〜/ Code / Komarnicki2 /wp-content/themes/komarnicki/gulpfile.js
[13:20:18]启动'all'...
[13:20:18]启动'sass'...
[13:20:19] 900 ms后完成'sass'
[13:20:19]启动'scripts'...
[13:20:19]完成'scripts'之后96 ms
[13:20:19]开始复制...
[13:20:19] 52 ms后完成'copy'
[13:20:19]开始'版本'...
[13:20:19] 56 ms后完成'版本'
[13:20:19] 1.11 s
[13:20后完成'all' :19]开始'默认'...
┌────────── ─────┬──────────────────────────┬───────────────── ────────────────────────────────────────────────── ─────────────────────────────────────
│任务│摘要│源文件│目标│
├───────────────┼──────────────────────────┼────── ────────────────────────────────────────────────── ────────────────────────────────────────────
│ mix.sass()│1.编译Sass│资产/ sass / app.scss│public / css / app.css│
││2.自动修复CSS│││
││3.连接文件│││
││4.书写来源地图│││
││5.储蓄至目的地│││
├────────────── ─┼──────────────────────────┼───────────────────── ──── ────────────────────────────────────────────────── ─┼─────────────────────┤
│mix.scripts()│1.连结文件│bower_components / fontfaceobserver / fontfaceobserver.js│public / js /all.js│
││2.编写源地图│assets / js / font.loader.js││
││3.保存到目的地│bower_components / jquery / dist / jquery.min。 js││
│││bower_components / foundation-sites / dist / foundation.min.js││
│││bower_components / moment / moment.js│ │
│││bower_components / moment / locale / pl.js││
│││bower_components / bLazy / blazy.js││
│││bower_components / jQuery-viewport-checker / dist / jquery.viewportchecker.min.js││
│││bower_components / slick-carousel / slick / slick.min.js││
│││bower_components / masonry / dist / masonry.pkgd。 js││
│││bower_components / imagesloaded / imagesloaded.pkgd.js││
││ │bower_components / magnific-popup / dist / jquery.magnific-popup.js││
│││assets / js / scripts.js││
│││assets / js / modules / *。js ││
│││assets / js / other / *。js││
├──────────────────────────────────── ─────────────────┼──────────────────────────────── ─────────────────────────────────────────────┼──── ─── ────────────┤
│mix.copy()│1.保存到目的地│assets / fonts // ** / *│public / fonts /│
├ ───────────────┼──────────────────────────┼─────── ────────────────────────────────────────────────── ─────────────────────────────────────
│mix.version ()│1.版本管理│public / css / app.css│public / build│
││2.重写文件路径│public / js / all.js││
││3.保存到Destina │││
││4.复制源地图│││
└────────────────────────────────────── ───────────────┴────────────────────────────────── ───────────────────────────────────────────┴────── ──────────────┘
[13:20:19] 6.65 ms后完成'default'

我仍然不知道为什么会发生这种情况。是不是因为最近我在创建 brew setup.shrel =nofollow noreferrer>我的shell脚本 brew install node )?我的问题解决了很好,但我不知道是什么原因造成的。仍然有人可以贡献并告诉我出了什么问题?


  • 为什么语法已被更改?

  • 为什么数组路径到达参数列表中的第4位?

  • 我怎样才能在将来避免这种情况?
  • >
  • 如果有人决定添加第5个,第6个参数?



那是因为依赖版本不匹配?现在我很害怕这种情况可能发生在未来......


In my Wordpress project I'm using Laravel Elixir to deal with assets. Everything was working till today.

Now every time I run gulp I'm getting:

$ gulp
path.js:7
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received { includePaths:
   [ 'bower_components/foundation-sites/scss/',
     'bower_components/slick-carousel/slick' ] }
    at assertPath (path.js:7:11)
    at Object.join (path.js:1211:7)
    at prefixOne (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/laravel-elixir/dist/tasks/GulpPaths.js:143:43)
    at GulpPaths.prefix (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/laravel-elixir/dist/tasks/GulpPaths.js:153:20)
    at GulpPaths.src (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/laravel-elixir/dist/tasks/GulpPaths.js:44:25)
    at getPaths (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/laravel-elixir/dist/tasks/recipes/sass.js:33:33)
    at Function.<anonymous> (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/laravel-elixir/dist/tasks/recipes/sass.js:21:33)
    at Function.<anonymous> (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/laravel-elixir/dist/bootstrap/EnableExtension.js:16:18)
    at /Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/gulpfile.js:7:9
    at global.Elixir (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/laravel-elixir/dist/index.js:21:5)

I thought that maybe there is something wrong with my node_modules directory, so I did rm -rf node_modules and then npm install as usual. Everything was pulled but at the end I saw:

├── UNMET PEER DEPENDENCY stream-browserify@*

I have no idea whether this unmet dependency is the reason. If this can help, this is the output of particular versions of the software I have:

node -v

v7.0.0

npm -v

3.10.8

gulp -v

[12:26:22] CLI version 3.9.1 [12:26:22] Local version 3.9.1

Here is my gulpfile.js.

It doesn't like an array from includePaths? Can I ask for some help? Thank you.

edit:

This is my package.json:

{
  "name": "slick",
  "version": "1.0.0",
  "devDependencies": {
    "gulp": "^3.9.1",
    "laravel-elixir": "^6.0.0-2"
  }
}

解决方案

This solution helped me: https://stackoverflow.com/a/40047852/4197938

The problem is that the options have been moved from the third to the fourth parameter.

So I simply added additional null before includePaths.

mix.sass('app.scss', null, null <- THIS IS THE SOLUTION, {

Then running gulp gave

$ gulp
[13:15:29] Using gulpfile ~/Code/Komarnicki2/wp-content/themes/komarnicki/gulpfile.js
[13:15:29] Starting 'all'...
[13:15:29] Starting 'sass'...
[13:15:29] 'sass' errored after 60 ms
[13:15:29] Error: Missing binding /Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/node-sass/vendor/darwin-x64-51/binding.node
Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 7.x

Found bindings for the following environments:
  - OS X 64-bit with Node.js 6.x

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to build the binding for your current environment.
    at Object.<anonymous> (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/node-sass/lib/index.js:15:11)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/gulp-sass/index.js:187:21)
    at Module._compile (module.js:573:32)
[13:15:29] 'all' errored after 63 ms
[13:15:29] Error in plugin 'run-sequence(sass)'
Message:
    Missing binding /Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/node-sass/vendor/darwin-x64-51/binding.node
Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 7.x

Found bindings for the following environments:
  - OS X 64-bit with Node.js 6.x

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to build the binding for your current environment.
Stack:
Error: Missing binding /Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/node-sass/vendor/darwin-x64-51/binding.node
Node Sass could not find a binding for your current environment: OS X 64-bit with Node.js 7.x

Found bindings for the following environments:
  - OS X 64-bit with Node.js 6.x

This usually happens because your environment has changed since running `npm install`.
Run `npm rebuild node-sass` to build the binding for your current environment.
    at Object.<anonymous> (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/node-sass/lib/index.js:15:11)
    at Module._compile (module.js:573:32)
    at Object.Module._extensions..js (module.js:582:10)
    at Module.load (module.js:490:32)
    at tryModuleLoad (module.js:449:12)
    at Function.Module._load (module.js:441:3)
    at Module.require (module.js:500:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/Users/slick/Code/Komarnicki2/wp-content/themes/komarnicki/node_modules/gulp-sass/index.js:187:21)
    at Module._compile (module.js:573:32)

so then I did exactly what was written in the output

npm rebuild node-sass

and the finally gulp did work

$ gulp
[13:20:18] Using gulpfile ~/Code/Komarnicki2/wp-content/themes/komarnicki/gulpfile.js
[13:20:18] Starting 'all'...
[13:20:18] Starting 'sass'...
[13:20:19] Finished 'sass' after 900 ms
[13:20:19] Starting 'scripts'...
[13:20:19] Finished 'scripts' after 96 ms
[13:20:19] Starting 'copy'...
[13:20:19] Finished 'copy' after 52 ms
[13:20:19] Starting 'version'...
[13:20:19] Finished 'version' after 56 ms
[13:20:19] Finished 'all' after 1.11 s
[13:20:19] Starting 'default'...
┌───────────────┬──────────────────────────┬─────────────────────────────────────────────────────────────────────────────┬────────────────────┐
│ Task          │ Summary                  │ Source Files                                                                │ Destination        │
├───────────────┼──────────────────────────┼─────────────────────────────────────────────────────────────────────────────┼────────────────────┤
│ mix.sass()    │ 1. Compiling Sass        │ assets/sass/app.scss                                                        │ public/css/app.css │
│               │ 2. Autoprefixing CSS     │                                                                             │                    │
│               │ 3. Concatenating Files   │                                                                             │                    │
│               │ 4. Writing Source Maps   │                                                                             │                    │
│               │ 5. Saving to Destination │                                                                             │                    │
├───────────────┼──────────────────────────┼─────────────────────────────────────────────────────────────────────────────┼────────────────────┤
│ mix.scripts() │ 1. Concatenating Files   │ bower_components/fontfaceobserver/fontfaceobserver.js                       │ public/js/all.js   │
│               │ 2. Writing Source Maps   │ assets/js/font.loader.js                                                    │                    │
│               │ 3. Saving to Destination │ bower_components/jquery/dist/jquery.min.js                                  │                    │
│               │                          │ bower_components/foundation-sites/dist/foundation.min.js                    │                    │
│               │                          │ bower_components/moment/moment.js                                           │                    │
│               │                          │ bower_components/moment/locale/pl.js                                        │                    │
│               │                          │ bower_components/bLazy/blazy.js                                             │                    │
│               │                          │ bower_components/jQuery-viewport-checker/dist/jquery.viewportchecker.min.js │                    │
│               │                          │ bower_components/slick-carousel/slick/slick.min.js                          │                    │
│               │                          │ bower_components/masonry/dist/masonry.pkgd.js                               │                    │
│               │                          │ bower_components/imagesloaded/imagesloaded.pkgd.js                          │                    │
│               │                          │ bower_components/magnific-popup/dist/jquery.magnific-popup.js               │                    │
│               │                          │ assets/js/scripts.js                                                        │                    │
│               │                          │ assets/js/modules/*.js                                                      │                    │
│               │                          │ assets/js/other/*.js                                                        │                    │
├───────────────┼──────────────────────────┼─────────────────────────────────────────────────────────────────────────────┼────────────────────┤
│ mix.copy()    │ 1. Saving to Destination │ assets/fonts//**/*                                                          │ public/fonts/      │
├───────────────┼──────────────────────────┼─────────────────────────────────────────────────────────────────────────────┼────────────────────┤
│ mix.version() │ 1. Versioning            │ public/css/app.css                                                          │ public/build       │
│               │ 2. Rewriting File Paths  │ public/js/all.js                                                            │                    │
│               │ 3. Saving to Destination │                                                                             │                    │
│               │ 4. Copying Source Maps   │                                                                             │                    │
└───────────────┴──────────────────────────┴─────────────────────────────────────────────────────────────────────────────┴────────────────────┘
[13:20:19] Finished 'default' after 6.65 ms

I still have no idea why all that happened. Was that because recently I was messing with brew stuff while creating my shell scripts (brew install node)? It's great that my problem is solved but I'm unhappy by not knowing what caused it. Still can someone contribute and tell me what went wrong?

  • Why the syntax has been changed?
  • Why array of paths went to 4-th place in the list of args?
  • How can I avoid that in the future?
  • What if someone will decide to add 5th, 6th arg?

Was that because of dependency version mismatch? Now I'm affraid that this can happen in the future as well...

这篇关于运行gulp给出“path.js:7 throw new TypeError('Path must be a string。Received'+ inspect(path));的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆