jaredpalmer / jaredpalmer/backpack
Using backpack as a global module on Windows
- Dominant language
- JavaScript
- Stars
- 4.4k
- Forks
- 164
- PR merge metrics
- No merged PRs in 30d
Description
Hi,
I have installed backpack-core globally (`npm i -g`) on my Windows and tested it on the [basic example)](https://github.com/jaredpalmer/backpack/tree/master/examples/basic) It was not working because of the first line of the main.js:
```js
require('C:\Users\Brendan\AppData\Roaming\npm\node_modules\backpack-core\node_modules\source-map-support\register.js')
```
Node as issues requiring modules with absolute path on windows. Replacing this first line the following fixes the problem.
```js
require('C:/Users/Brendan/AppData/Roaming/npm/node_modules/backpack-core/node_modules/source-map-support/register.js')
```
A dirty fix would be to replace the separators [here](https://github.com/jaredpalmer/backpack/blob/a81a671fd5e3219f3fc931a0c0242b553bcbe202/packages/backpack-core/config/webpack.config.js#L115-L126).
```js
new webpack.BannerPlugin({
raw: true,
entryOnly: false,
banner: `require('${
// Is source-map-support installed as project dependency, or linked?
( require.resolve('source-map-support').indexOf(process.cwd()) === 0 )
// If it's resolvable from the project root, it's a project dependency.
? 'source-map-support/register'
// It's not under the project, it's linked via lerna.
: require.resolve('source-map-support/register').replace(/\\/g, '/')
}')`
}),
```
cheers,
Contributor guide
Research direction
Start in packages/backpack-core/config/webpack.config.js at the BannerPlugin configuration around lines 115-126, then inspect the examples/basic main.js entry point. Reproduce the global installation problem on Windows and verify that the basic example runs with the generated require path using Windows separators handled correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, node.js, webpack
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100