简体   繁体   English

运行gulp会导致“ path.js:7抛出新的TypeError('路径必须是字符串。已接收'+ inspect(path));”

[英]Running gulp gives “path.js:7 throw new TypeError('Path must be a string. Received ' + inspect(path));”

In my Wordpress project I'm using Laravel Elixir to deal with assets. 在我的Wordpress项目中,我正在使用Laravel Elixir处理资产。 Everything was working till today. 直到今天一切都在运转。

Now every time I run gulp I'm getting: 现在,每次我大gulp我都会得到:

$ 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. 我以为node_modules目录可能有问题,所以我做了rm -rf node_modules ,然后像往常一样npm install 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 7.0.0

npm -v

3.10.8 3.10.8

gulp -v

[12:26:22] CLI version 3.9.1 [12:26:22] Local version 3.9.1 [12:26:22] CLI版本3.9.1 [12:26:22]本地版本3.9.1

Here is my gulpfile.js . 这是我的gulpfile.js

It doesn't like an array from includePaths ? 它不喜欢includePaths的数组吗? Can I ask for some help? 我可以寻求帮助吗? Thank you. 谢谢。

edit: 编辑:

This is my package.json: 这是我的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 这个解决方案对我有帮助: 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 . 因此,我只是在includePaths之前添加了其他null

mix.sass('app.scss', null, null <- THIS IS THE SOLUTION, { mix.sass('app.scss',null,null <-这是解决方案,{

Then running gulp gave 然后大gulp

$ 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

$ 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 )? 那是因为最近我在创建Shell脚本brew install node )时弄乱了brew东西吗? 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? 为什么路径数组在args列表中排第四位?
  • How can I avoid that in the future? 将来如何避免这种情况?
  • What if someone will decide to add 5th, 6th arg? 如果有人决定添加第5,第6参数,该怎么办?

Was that because of dependency version mismatch? 那是因为依赖版本不匹配吗? Now I'm affraid that this can happen in the future as well... 现在我很害怕这种情况将来也会发生...

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 gulp-usemin TypeError:路径必须是字符串。 收到未定义 - gulp-usemin TypeError: Path must be a string. Received undefined 自定义Gulp.js插件:TypeError“路径必须是一个字符串。 收到undefined“ - Custom Gulp.js plugin: TypeError “Path must be a string. Received undefined” gulp Iconify任务引发错误TypeError:路径必须是字符串。 收到假 - gulp Iconify task throws error TypeError: Path must be a string. Received false Jest TypeError:路径必须是字符串。 收到未定义 - Jest TypeError: Path must be a string. Received undefined Firebase 与 react: TypeError: Path must be a string。 收到未定义 - Firebase with react: TypeError: Path must be a string. Received undefined Node.js 应用程序类型错误 [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 接收类型对象 - Node.js app TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type object TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 收到 Object 的实例 - TypeError [ERR_INVALID_ARG_TYPE]: The “path” argument must be of type string. Received an instance of Object Grunt“watch”警告:Path必须是一个字符串。 收到undefined - Grunt “watch” Warning: Path must be a string. Received undefined Jest测试失败“TypeError:Path必须是一个字符串。 收到未定义的“ - Jest test failed “TypeError: Path must be a string. Recieved undefined” 错误:TypeError [ERR_INVALID_ARG_TYPE]:“路径”参数必须是字符串类型。 尝试 node utils/nftport/uploadFiles.js 时收到 undefined - error:TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received undefined when trying node utils/nftport/uploadFiles.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM