Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Module not found: Error: Cannot resolve module 'pace' #328

Open
Splintex opened this issue Jun 8, 2016 · 34 comments
Open

Module not found: Error: Cannot resolve module 'pace' #328

Splintex opened this issue Jun 8, 2016 · 34 comments

Comments

@Splintex
Copy link

Splintex commented Jun 8, 2016

Bug when I use it with webpack. Could you fix here https://www.npmjs.com/package/pace-progress ?

@voipme2
Copy link

voipme2 commented Jun 30, 2016

+1

I'm running into this issue as well. Both import pace from 'pace-progress'; and require('pace-progress'); cause the build to fail.

@genarorg
Copy link

Have you guys find a solution for this?

@ymatuhin
Copy link

+1

@don-bluelinegrid
Copy link

+1
same for me:

Can't resolve 'pace'

@Jbarget
Copy link

Jbarget commented Aug 8, 2016

+1

@Jbarget
Copy link

Jbarget commented Aug 8, 2016

I managed to get around this by running npm install pace --save

ie. installing pace explicitly into the root of the node_modules folder

@andresmatasuarez
Copy link

+1

The workaround proposed by @Jbarget works for me also. But I prefer a solution from the module authors

@Jbarget
Copy link

Jbarget commented Aug 10, 2016

of course, at the moment if you use my workaround you'll have 2 copies of pace installed on the project which is unnecessary (one in the root and the other nested within pace-progress. hoping it will only be temporary

@andresmatasuarez
Copy link

@Jbarget Yeah, I also hope it will be temporary. By the way, isn't there a way to make 'pace' resolve to the nested pace module? Like using Webpack's alias or something like that.

@Jbarget
Copy link

Jbarget commented Aug 10, 2016

good point! im working on other functionality at the moment but will definitely revisit this

@andresmatasuarez
Copy link

@Jbarget I will also give it a look when I had a little more time

@fson
Copy link

fson commented Sep 11, 2016

The problem is that the AMD define in pace.js is incorrect:

define(['pace'], function() {
  return Pace;
});

(This defines a pace as a dependency, and pace on npm is an unrelated CLI progress bar package that this project doesn't depend on.)

Correct define would be this (naming the module in the define call should be avoided):

define(function() {
  return Pace;
});

@yfilali
Copy link

yfilali commented Sep 20, 2016

To get around this until it's fixed, just disable amd for pace-progress:

{ test: require.resolve("pace-progress"), loader: "imports?define=>false" }

this requires the imports loader for webpack:
npm install imports-loader --save-dev

After that, you can just import it as usual:
import Pace from 'pace-progress';

@Lewiscowles1986
Copy link

Sorry for not being involved in the discussion, but I just got this error today and it seems an easy enough fix

  • update pace.coffee
  • npm install && grunt
  • git push

Hopefully I've not missed anything, sorry if I did, I'd love to know what so I don't make the mistake again.

Anyone using https://github.com/bigcommerce/stencil, I'll be pushing a patch to that too

Lewiscowles1986 added a commit to Lewiscowles1986/stencil that referenced this issue Oct 21, 2016
Please see CodeByZach/pace#328 (comment)

Without this patch I cannot get a clean build of stencil in [my Docker setup](https://gist.github.com/Lewiscowles1986/d4ef75a2d9c3e7d6e1794c3e90246c9a)
@Lewiscowles1986
Copy link

bump please

@amandeepsinghvirdi
Copy link

I am still getting the issue in stencil

@Lewiscowles1986
Copy link

Stencil has updated. Hubspot AFAIK has done nothing so you'll have to manually patch hubspot pace from my repo ATM

bc-adamferenzi pushed a commit to bc-adamferenzi/stencil that referenced this issue Nov 15, 2016
Please see CodeByZach/pace#328 (comment)

Without this patch I cannot get a clean build of stencil in [my Docker setup](https://gist.github.com/Lewiscowles1986/d4ef75a2d9c3e7d6e1794c3e90246c9a)
@maffelbaffel
Copy link

How can this still not be fixed? :(
@yfilali's workaround works great thought.

@raphaelsoul
Copy link

@yfilali
this configuration is not valid for webpack 2.0. If you use 2.0, pls write full loader name like this:

{
    test: require.resolve("pace-progress"),
    loader: "imports-loader?define=>false"
 }

@htchaan
Copy link

htchaan commented Feb 28, 2017

A quick fix is to fulfil it temporarily with:

npm install --save-dev github:HubSpot/pace#v1.0.2

@bonesoul
Copy link

anyone managed to get this working in webpack 2?

my code;

require('pace-progress');

      {
        test: require.resolve("pace-progress"),
        loader: "imports-loader?define=>false"
      }

@yozman
Copy link

yozman commented May 28, 2017

with webpack2 just need

resolve: {
  alias: {
    pace: 'pace-progress'
  }
}

@CoolGoose
Copy link

Unfortunately this is still an issue, but @yozman fix works in webpack 3 as well. Is there a bigger fork we can point to, or can we discuss a 'pace' organization and get a few people on board ?

@gbluv
Copy link

gbluv commented Jan 25, 2018

Pace is such an amazing library could you please fix the loading part via Import?

Thanks in advance.

-Greg

@iShawnWang
Copy link

No hero willing to save the world here !

:(

@arnoldrch
Copy link

In my symfony webpack i use:

require('imports-loader?define=>false?pace-js');

@abarke
Copy link

abarke commented Mar 13, 2018

Incredible that this hasn't been solved yet. It's just a one liner and would resolve so much pain!

As @yfilali states just replace the following here:

define(['pace'], function() {
  return Pace;
});

with

define(function() {
  return Pace;
});

and the world is a happier place :)

@chebaby
Copy link

chebaby commented Apr 4, 2018

the @yozman solution works well for me with webpack ^3.11
but i ended using this solution :

module: {
        rules: [
        	{ 
        		test: require.resolve("pace-progress"), 
        		loader: "imports-loader?define=>false"
        	}
        ]
}

silentium-tayfoon added a commit to silentium-tayfoon/pace that referenced this issue Jun 25, 2018
Solve problem with "Module not found: Error: Can't resolve 'pace' in..."
by
CodeByZach#328 (comment)
@jklimke
Copy link

jklimke commented Jul 12, 2018

thanks for publishing this as pace-js-amd-fix npm module

@robert-cronin
Copy link

thankyou @chebaby for the fix 👍 it worked for my situation (kotlin and webpack)

@broadcoder
Copy link

broadcoder commented Jun 6, 2020

Thanks for all the hints, guys!
I finally fixed it for symfony webpack encore with your help:

    // fix pace js import
    .addLoader({
        use: 'imports-loader?define=>false',
        test: require.resolve('pace-js')
    })

@glen-84
Copy link

glen-84 commented Dec 24, 2021

I don't see this problem with webpack 5, maybe this issue can be closed?

@barbuslex
Copy link

barbuslex commented Mar 14, 2023

@glen-84 webpack encore is always on webpack 4 :S

This workaround works for me :

  1. add imports-loader : yarn add -D imports-loader (not easy to guess ^^)
  2. add this in webpack.config.js :
// fix pace-js import
.addLoader({
    test: require.resolve('pace-js'),
    use: [{
        loader: 'imports-loader',
        options: {
            additionalCode: 'var define = false;'
        }
    }]
})
  1. run yarn build

@glen-84
Copy link

glen-84 commented Mar 14, 2023

@glen-84 webpack encore is always on webpack 4 :S

symfony/webpack-encore#880

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests