# Error when running Sage build:production

**URL:** https://discourse.roots.io/t/error-when-running-sage-build-production/7120
**Category:** sage
**Created:** 2016-07-01T20:03:46Z
**Posts:** 11

## Post 1 by @Arc — 2016-07-01T20:03:46Z

Hi there,

Encountering an issue when trying to run the webpack build:production task as per described here: [https://github.com/roots/sage/tree/sage-9](https://github.com/roots/sage/tree/sage-9)

Both the build and watch tasks work fine, but the build:production throws an error in emitpath.js.

I believe it’s trying to supply an object instead of a string as an argument. Tested on a clean bedrock+sage install, all the latest versions of composer, npm, and node installed.

**Terminal Output**

```
npm run build:production

> sage@9.0.0 build:production /Users/ **** /Sites/sandbox/bedrock/web/app/themes/sage
> webpack -p --progress --release

clean-webpack-plugin: /Users/ **** /Sites/sandbox/bedrock/web/app/themes/sage/dist has been removed.
 90% optimize assets        
Starting to optimize CSS...
Processing styles/main_e286f6c47431638eb560.css...
Processed styles/main_e286f6c47431638eb560.css, before: 140014, after: 139623, ratio: 99.72%
 95% emitpath.js:7
    throw new TypeError('Path must be a string. Received ' + inspect(path));
    ^

TypeError: Path must be a string. Received { js: 'scripts/main_e286f6c47431638eb560.js',
  css: 'styles/main_e286f6c47431638eb560.css' }
    at assertPath (path.js:7:11)
    at Object.extname (path.js:1433:5)
    at Object.assetsPluginProcessOutput [as processOutput] (/Users/ **** /Sites/sandbox/bedrock/web/app/themes/sage/webpack.config.js:47:16)
    at ReadFileContext.callback (/Users/ **** /Sites/sandbox/bedrock/web/app/themes/sage/node_modules/assets-webpack-plugin/lib/output/createOutputWriter.js:43:30)
    at FSReqWrap.readFileAfterOpen [as oncomplete] (fs.js:359:13)

npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build:production"
npm ERR! node v6.2.2
npm ERR! npm v3.10.2
npm ERR! code ELIFECYCLE
npm ERR! sage@9.0.0 build:production: `webpack -p --progress --release`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the sage@9.0.0 build:production script 'webpack -p --progress --release'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the sage package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! webpack -p --progress --release
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs sage
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls sage
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR! /Users/ **** /Sites/sandbox/bedrock/web/app/themes/sage/npm-debug.log
```

**npm-debug.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 'build:production' ]
2 info using npm@3.10.2
3 info using node@v6.2.2
4 verbose run-script [ 'prebuild:production',
4 verbose run-script 'build:production',
4 verbose run-script 'postbuild:production' ]
5 info lifecycle sage@9.0.0~prebuild:production: sage@9.0.0
6 silly lifecycle sage@9.0.0~prebuild:production: no script for prebuild:production, continuing
7 info lifecycle sage@9.0.0~build:production: sage@9.0.0
8 verbose lifecycle sage@9.0.0~build:production: unsafe-perm in lifecycle true
9 verbose lifecycle sage@9.0.0~build:production: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/ **** /Sites/sandbox/bedrock/web/app/themes/sage/node_modules/.bin:/usr/local/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
10 verbose lifecycle sage@9.0.0~build:production: CWD: /Users/ **** /Sites/sandbox/bedrock/web/app/themes/sage
11 silly lifecycle sage@9.0.0~build:production: Args: ['-c', 'webpack -p --progress --release']
12 silly lifecycle sage@9.0.0~build:production: Returned: code: 1 signal: null
13 info lifecycle sage@9.0.0~build:production: Failed to exec build:production script
14 verbose stack Error: sage@9.0.0 build:production: `webpack -p --progress --release`
14 verbose stack Exit status 1
14 verbose stack at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:242:16)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at EventEmitter.emit (events.js:191:7)
14 verbose stack at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack at emitTwo (events.js:106:13)
14 verbose stack at ChildProcess.emit (events.js:191:7)
14 verbose stack at maybeClose (internal/child_process.js:852:16)
14 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
15 verbose pkgid sage@9.0.0
16 verbose cwd /Users/ **** /Sites/sandbox/bedrock/web/app/themes/sage
17 error Darwin 15.5.0
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build:production"
19 error node v6.2.2
20 error npm v3.10.2
21 error code ELIFECYCLE
22 error sage@9.0.0 build:production: `webpack -p --progress --release`
22 error Exit status 1
23 error Failed at the sage@9.0.0 build:production script 'webpack -p --progress --release'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the sage package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error webpack -p --progress --release
23 error You can get information on how to open an issue for this project with:
23 error npm bugs sage
23 error Or if that isn't available, you can get their info via:
23 error npm owner ls sage
23 error There is likely additional logging output above.
24 verbose exit [1, true]
```

---

## Post 2 by @Nicolo_Sacchi — 2016-07-02T04:06:05Z

have a look here

> [@Whats the purpose of assetsPluginProcessOutput?](https://discourse.roots.io/t/whats-the-purpose-of-assetspluginprocessoutput/6851/3):
>
> Hi, EDIT: It’s working now. Here is the fix: [https://github.com/roots/sage/issues/1659#issuecomment-223032889](https://github.com/roots/sage/issues/1659#issuecomment-223032889) Regards

---

## Post 3 by @Arc — 2016-07-02T08:17:53Z

Thanks! dani-z’s solution of changing path.extname() to path.format() in webpack.config.js worked.

---

## Post 4 by @Twansparant — 2017-03-09T14:46:22Z

Thanks for this fix!

---

## Post 5 by @bdebever — 2017-09-11T16:39:02Z

Hi guys,

I am experiencing the same issue with Sage 9 ; no solution so far.

Any idea?

Thanks.

---

## Post 6 by @MWDelaney — 2017-09-11T16:41:58Z

We’re going to need a little more information than that. What have you tried?

---

## Post 7 by @bdebever — 2017-09-11T16:55:12Z

Hi,

Thanks for your answer.

So I ran `yarn run build:production` and I got the following error:

```
$ webpack --progress -p --config resources/assets/build/webpack.config.js
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.`````

Thanks.
```

---

## Post 8 by @MWDelaney — 2017-09-11T17:55:28Z

Is this a vanilla copy of Sage, straight out of the box, or have you customized it at all before running `yarn build:production` ?

---

## Post 9 by @bdebever — 2017-09-11T19:29:01Z

Well, I made some changes (added npm packages mainly).  
thanks.

---

## Post 10 by @MWDelaney — 2017-09-11T19:36:07Z

I recommend removing the packages one by one and seeing which one causes it to break or un-break when added/removed. This will narrow down where the problem is. Once you know which package caused the issue, show us how you added the package and what changes you made to `theme-name/resources/assets/scripts/*`

---

## Post 11 by @bdebever — 2017-09-12T13:27:36Z

Hi there,

Thanks for that - I found the culprit.

This is this plugin: [http://idangero.us/swiper/#.Wbfge9OGNE4](http://idangero.us/swiper/#.Wbfge9OGNE4)

I installed it from my package.json

then, I basically import it at the top of my home.js using:  
`import Swiper from "swiper";`

And then in my finalize() function:

```
new Swiper ('.swiper-container', {
          // Optional parameters
          //loop: true,
          slidesPerView: 3,
          paginationClickable: true,
          spaceBetween: 30,
          freeMode: true,
          //centeredSlides: true,
          autoplay: 2500,
          // Navigation arrows
          nextButton: '.swiper-button-next',
          prevButton: '.swiper-button-prev',
          breakpoints: {
              1024: {
                  slidesPerView: 4,
                  spaceBetween: 40,
              },
              768: {
                  slidesPerView: 3,
                  spaceBetween: 30,
              },
              640: {
                  slidesPerView: 2,
                  spaceBetween: 20,
              },
              320: {
                  slidesPerView: 1,
                  spaceBetween: 10,
              },
          },

      });
```
