pace icon indicating copy to clipboard operation
pace copied to clipboard

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

Open Splintex opened this issue 8 years ago • 34 comments

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

Splintex avatar Jun 08 '16 14:06 Splintex

+1

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

voipme2 avatar Jun 30 '16 16:06 voipme2

Have you guys find a solution for this?

genarorg avatar Jul 19 '16 23:07 genarorg

+1

ymatuhin avatar Jul 31 '16 18:07 ymatuhin

+1 same for me:

Can't resolve 'pace'

don-bluelinegrid avatar Aug 05 '16 18:08 don-bluelinegrid

+1

Jbarget avatar Aug 08 '16 13:08 Jbarget

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

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

Jbarget avatar Aug 08 '16 15:08 Jbarget

+1

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

andresmatasuarez avatar Aug 10 '16 02:08 andresmatasuarez

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

Jbarget avatar Aug 10 '16 11:08 Jbarget

@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.

andresmatasuarez avatar Aug 10 '16 11:08 andresmatasuarez

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

Jbarget avatar Aug 10 '16 11:08 Jbarget

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

andresmatasuarez avatar Aug 10 '16 12:08 andresmatasuarez

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;
});

fson avatar Sep 11 '16 22:09 fson

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';

yfilali avatar Sep 20 '16 19:09 yfilali

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 avatar Oct 21 '16 15:10 Lewiscowles1986

bump please

Lewiscowles1986 avatar Nov 04 '16 00:11 Lewiscowles1986

I am still getting the issue in stencil

amandeepsinghvirdi avatar Nov 10 '16 00:11 amandeepsinghvirdi

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

Lewiscowles1986 avatar Nov 10 '16 10:11 Lewiscowles1986

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

maffelbaffel avatar Jan 07 '17 19:01 maffelbaffel

@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"
 }

raphaelsoul avatar Feb 01 '17 12:02 raphaelsoul

A quick fix is to fulfil it temporarily with:

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

htchaan avatar Feb 28 '17 08:02 htchaan

anyone managed to get this working in webpack 2?

my code;

require('pace-progress');

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

bonesoul avatar Apr 14 '17 08:04 bonesoul

with webpack2 just need

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

yozman avatar May 28 '17 08:05 yozman

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 ?

CoolGoose avatar Nov 09 '17 14:11 CoolGoose

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

Thanks in advance.

-Greg

gbluv avatar Jan 25 '18 20:01 gbluv

No hero willing to save the world here !

:(

iShawnWang avatar Feb 09 '18 18:02 iShawnWang

In my symfony webpack i use:

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

arnoldrch avatar Mar 08 '18 14:03 arnoldrch

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 :)

abarke avatar Mar 13 '18 17:03 abarke

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"
        	}
        ]
}

chebaby avatar Apr 04 '18 10:04 chebaby

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

jklimke avatar Jul 12 '18 13:07 jklimke

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

robert-cronin avatar May 16 '19 15:05 robert-cronin