在es6环境搭建中gulp安装遇到的问题

来源:互联网 发布:cf网站源码 编辑:程序博客网 时间:2024/06/05 08:09

gulpjs的使用介绍及技巧请参考之前转载的文章http://blog.csdn.net/zhanglir333/article/details/78577895


这里讲的是遇到的问题:

安装完成之后,运行gulp -v出现

 -bash: gulpcommand not found

然后查阅了相关文章 
https://segmentfault.com/a/1190000011201373
https://www.zhihu.com/question/36023122
https://segmentfault.com/q/1010000003407181
根据这些文章修改完成后,还是出现

 -bash: gulpcommand not found

有问题一直改不过真的让人很崩溃,连着两天被同一个问题困扰,后来想了想是不是应该是npm install安装的都不对的呀,然后就换了一种方式开始查找答案,最终根据
http://blog.csdn.net/tp7309/article/details/78287952和
https://www.cnblogs.com/WaTa/p/6825722.html
http://blog.csdn.net/travelzhang/article/details/51261407
三篇文章进行修改环境变量中的用户变量

C:\Users\LiRong\AppData\Local\Temp\360zip$Temp\360$5\UltraEdit\;E:\Program Files\Fiddler;C:\Users\LiRong\AppData\Roaming\npm;E:\Program Files\nodejs\node_modules\npm
后边是自己添加的
npm prefix -g
  • 1

将输出的全局安装路径加入的环境变量的Path条目中即可。

然后就解决了问题,希望可以帮助大家

$ gulp
[16:14:36] Requiring external module babel-register
[16:14:49] Using gulpfile E:\BaiduYunDownload\es6\gulpfile.babel.js
[16:14:49] Starting 'build'...
[16:14:49] Starting 'clean'...
[16:14:49] Finished 'clean' after 20 ms
[16:14:49] Starting 'css'...
[16:14:49] Finished 'css' after 12 ms
[16:14:49] Starting 'pages'...
[16:14:49] Finished 'pages' after 21 ms
[16:14:49] Starting 'scripts'...
[16:14:49] Plumber found unhandled error:
 Error in plugin 'webpack-stream'
Message:
    multi ./app/js/index.js
Module not found: Error: Can't resolve 'babel' in 'E:\BaiduYunDownload\es6'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
                 You need to specify 'babel-loader' instead of 'babel',
                 see https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed
resolve 'babel' in 'E:\BaiduYunDownload\es6'
  Parsed request is a module
  using description file: E:\BaiduYunDownload\es6\package.json (relative path: .)
  after using description file: E:\BaiduYunDownload\es6\package.json (relative path: .)
    resolve as module
      E:\BaiduYunDownload\node_modules doesn't exist or is not a directory
      E:\node_modules doesn't exist or is not a directory
      looking for modules in E:\BaiduYunDownload\es6\node_modules
        using description file: E:\BaiduYunDownload\es6\package.json (relative path: ./node_modules)
        after using description file: E:\BaiduYunDownload\es6\package.json (relative path: ./node_modules)
          using description file: E:\BaiduYunDownload\es6\package.json (relative path: ./node_modules/babel)
            no extension
              E:\BaiduYunDownload\es6\node_modules\babel doesn't exist
            .js
              E:\BaiduYunDownload\es6\node_modules\babel.js doesn't exist
            .json
              E:\BaiduYunDownload\es6\node_modules\babel.json doesn't exist
            as directory
              E:\BaiduYunDownload\es6\node_modules\babel doesn't exist
[E:\BaiduYunDownload\node_modules]
[E:\node_modules]
[E:\BaiduYunDownload\es6\node_modules\babel]
[E:\BaiduYunDownload\es6\node_modules\babel.js]
[E:\BaiduYunDownload\es6\node_modules\babel.json]
[E:\BaiduYunDownload\es6\node_modules\babel]
 @ multi ./app/js/index.js
[16:14:49] Version: webpack 3.8.1
   Asset     Size  Chunks             Chunk Names
index.js  2.62 kB       0  [emitted]  index


ERROR in multi ./app/js/index.js
Module not found: Error: Can't resolve 'babel' in 'E:\BaiduYunDownload\es6'
BREAKING CHANGE: It's no longer allowed to omit the '-loader' suffix when using loaders.
                 You need to specify 'babel-loader' instead of 'babel',
                 see https://webpack.js.org/guides/migrating/#automatic-loader-module-name-extension-removed
 @ multi ./app/js/index.js
[16:14:49] Finished 'scripts' after 395 ms
[16:14:49] Starting 'browser'...
[16:14:49] Finished 'browser' after 79 μs
[16:14:49] Starting 'serve'...
[16:14:49] Finished 'serve' after 102 μs
[16:14:49] Finished 'build' after 539 ms
[16:14:49] Starting 'default'...
[16:14:49] Finished 'default' after 24 μs


出现该问题时,可以修改tasks/scripts.js中的

module:{    loaders:[{        test:/\.js$/,        loader:'babel'    }]}
将babel改为babel-loader即可。

原创粉丝点击