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

Moving from 8.0.2 to 8.1.2 causes many "Cannot resolve module" errors with Webpack. #220

Closed
dschissler opened this issue Jul 4, 2016 · 23 comments

Comments

@dschissler
Copy link

I'm using:

  • webpack 1.13.1
  • postcss 5.0.21
  • postcss-cssnext 2.5.2

When I bump from postcss-import 8.0.2 to 8.1.2 then I get the following errors:

ERROR in ./~/request/lib/har.js
Module not found: Error: Cannot resolve module 'fs' in /project_path/node_modules/request/lib
 @ ./~/request/lib/har.js 3:9-22

ERROR in ./~/forever-agent/index.js
Module not found: Error: Cannot resolve module 'net' in /project_path/node_modules/forever-agent
 @ ./~/forever-agent/index.js 6:10-24

ERROR in ./~/forever-agent/index.js
Module not found: Error: Cannot resolve module 'tls' in /project_path/node_modules/forever-agent
 @ ./~/forever-agent/index.js 7:10-24

ERROR in ./~/tough-cookie/lib/cookie.js
Module not found: Error: Cannot resolve module 'net' in /project_path/node_modules/tough-cookie/lib
 @ ./~/tough-cookie/lib/cookie.js 32:10-24

ERROR in ./~/form-data/lib/form_data.js
Module not found: Error: Cannot resolve module 'fs' in /project_path/node_modules/form-data/lib
 @ ./~/form-data/lib/form_data.js 7:9-22

ERROR in ./~/tunnel-agent/index.js
Module not found: Error: Cannot resolve module 'net' in /project_path/node_modules/tunnel-agent
 @ ./~/tunnel-agent/index.js 3:10-24

ERROR in ./~/tunnel-agent/index.js
Module not found: Error: Cannot resolve module 'tls' in /project_path/node_modules/tunnel-agent
 @ ./~/tunnel-agent/index.js 4:10-24

I tried adding the following to my webpack config but it doesn't work:

  node: {
    net: 'empty',
    tls: 'empty',
    fs: 'empty'
  },
@glennreyes
Copy link

Same here

@Garbee
Copy link

Garbee commented Jul 15, 2016

Can you please provide some sample code that produces this problem?

@dschissler
Copy link
Author

I don't think that I will be able to do that soon. All of my environments are quite complex.

@s-panferov
Copy link

Can't use this version with webpack:

ERROR in (webpack)/hot/only-dev-server.js
Module build failed: (SystemJS) ENOENT: no such file or directory, open '/Users/panferov/Workspace/revjet/csp-react/demo/fs'
    Error: ENOENT: no such file or directory, open '/Users/panferov/Workspace/revjet/csp-react/demo/fs'
        at Error (native)
    Error loading /Users/panferov/Workspace/revjet/csp-react/demo/fs as "fs" from /Users/panferov/Workspace/revjet/csp-webpack/src/babel-loader.js
 @ multi index

ERROR in (webpack)-dev-server/client?http://localhost:8080
Module build failed: (SystemJS) ENOENT: no such file or directory, open '/Users/panferov/Workspace/revjet/csp-react/demo/fs'
    Error: ENOENT: no such file or directory, open '/Users/panferov/Workspace/revjet/csp-react/demo/fs'
        at Error (native)
    Error loading /Users/panferov/Workspace/revjet/csp-react/demo/fs as "fs" from /Users/panferov/Workspace/revjet/csp-webpack/src/babel-loader.js
 @ multi index

ERROR in ./src/entry.js
Module build failed: (SystemJS) ENOENT: no such file or directory, open '/Users/panferov/Workspace/revjet/csp-react/demo/path'
    Error: ENOENT: no such file or directory, open '/Users/panferov/Workspace/revjet/csp-react/demo/path'
        at Error (native)
    Error loading /Users/panferov/Workspace/revjet/csp-react/demo/path as "path" from /Users/panferov/Workspace/revjet/csp-webpack/node_modules/react-hot-loader/index.js
 @ multi index

All require calls in js files are broken.

@longlho
Copy link

longlho commented Jul 29, 2016

I'm seeing this issue also, this is a snippet of my webpack config:

const plugins = [
    new webpack.DefinePlugin({
        'process.env': {
            NODE_ENV: '"production"'
        }
    }),
    new webpack.ProvidePlugin({
        React: 'react'
    })
]

if (process.env.NODE_ENV === 'production') {
    plugins.push(
        new webpack.optimize.UglifyJsPlugin({
            compress: {
                warnings: false
            },
            output: {
                comments: false
            }
        })
    );
}


module.exports = [
    {
        entry: entries,
        output: {
            path: join(__dirname, 'demo/dist'),
            publicPath: '/dist/',
            filename: '[name].out.js'
        },
        devtool: 'source-map',
        resolve: {
            extensions: ['', '.js', '.json', '.css'],
            alias: {
                'react': __dirname + '/node_modules/react'
            }
        },
        module: {
            loaders: [
                {
                    test: /\.css$/,
                    loader: 'style!css?modules&importLoaders=1!postcss'
                },
                {
                    test: /\.json$/,
                    loader: 'json'
                },
                {
                    test: /\.js$/,
                    exclude: /node_modules/,
                    loader: 'babel?cacheDirectory'
                }
            ]
        },
        postcss (wp) {
            return [
                require('postcss-import')({
                    addDependencyTo: wp
                }),
                require('postcss-cssnext')({
                    browsers: [
                        '> 1%',
                        'last 2 versions',
                        'Firefox ESR',
                        'iOS 8',
                        'ie >= 10'
                    ]
                }),
                require('postcss-reporter')()
            ];
        },
        plugins
    }
];

ping @Garbee

@longlho
Copy link

longlho commented Jul 29, 2016

some more details: [email protected] works, but not 8.1.1 or 8.1.2

@Garbee
Copy link

Garbee commented Jul 29, 2016

Sorry, don't have the time to look into this myself anymore. We are using Sass now for import/mixins/etc. Then using PostCSS to supplement that with the pieces that will go to browsers like color and custom properties.

@MoOx
Copy link
Contributor

MoOx commented Jul 29, 2016

Guys, use v7, see #210

@glennreyes
Copy link

I agree with [email protected] working on my machine as well.

I'm getting following error if I try to run karma with 8.1.1:

ERROR in ./internals/testing/testbundler.js
Module build failed: (SystemJS) ENOENT: no such file or directory, open '/Users/glennreyes/Projects/iwannahelp/babel-core'
    Error: ENOENT: no such file or directory, open '/Users/glennreyes/Projects/iwannahelp/babel-core'
        at Error (native)
    Error loading /Users/glennreyes/Projects/iwannahelp/babel-core as "babel-core" from /Users/glennreyes/Projects/iwannahelp/node_modules/babel-loader/index.js

cc @longlho

@langri-sha
Copy link

Have configuration comparable to @longlho. I'm a new user, so if my feedback is of any help, issue only became apparent after adding a url() in the stylesheet.

langri-sha added a commit to nevenagaj/praline that referenced this issue Aug 4, 2016
Newer releases cause issues with Webpack postcss/postcss-import#220
@KidkArolis
Copy link

Might be related to webpack/webpack#2901? I have a repo that reproduces the bug here: https://github.com/KidkArolis/webpack-2-failing-build. If this is unrelated - let me know and I'll post this as a separate issue.

@MoOx
Copy link
Contributor

MoOx commented Aug 22, 2016

It seems nobody reads other issues #210.

@wmertens
Copy link

Just pointing out that the reason of this breaking is explained at webpack/webpack#2411 (comment)

@Jessidhia
Copy link

Version 8.1.3 was released that still has this issue.

Current master has a commit that makes the jspm dependency optional, but that still won't help as npm will still install it, unless you disable optional dependencies; but if you do, it then won't install desirable optional dependencies like fsevents.

Unfortunately there are no "optional peerDependencies" :/

@dschissler
Copy link
Author

I was having this issue when I was using ampersand packages but once I switched to vue then I was able to upgrade to 8.1.2.

@RyanZim
Copy link
Collaborator

RyanZim commented Nov 7, 2016

Version 8.1.3 was released that still has this issue.

I know, v8.1.3 only fixed #168.

Current master has a commit that makes the jspm dependency optional, but that still won't help as npm will still install it, unless you disable optional dependencies; but if you do, it then won't install desirable optional dependencies like fsevents.

Yeah, I wasn't thinking when I did that. I'm currently considering adding a jspm option to turn off jspm resolving; see #212.

@RyanZim
Copy link
Collaborator

RyanZim commented Nov 16, 2016

A PR (hopefully) fixing this has been merged to the v9-dev branch (#243). Can someone install the v9-dev branch in their project and confirm that this issue is fixed on that branch? Thanks!

@amankkg
Copy link

amankkg commented Nov 17, 2016

@RyanZim in my case this issue still remains. Currently I'm on 8.1.0 + [email protected] and configured PostCSS via package.json. The error I get with v9 is similar to error from 8.1.1 (and up to 8.2.0).

@RyanZim
Copy link
Collaborator

RyanZim commented Nov 17, 2016

@code4aman Can you post the error message here?

@amankkg
Copy link

amankkg commented Nov 18, 2016

@RyanZim here it is.

error log
ERROR in ./client/helpers/fetch.js
Module build failed: (SystemJS) ENOENT: no such file or directory, open 'C:\Users\amank\dev\projname\C:\Users\amank\dev\projname\node_modules\babel-loader\index.js'
        Error: ENOENT: no such file or directory, open 'C:\Users\amank\dev\projname\C:\Users\amank\dev\projname\node_modules\babel-loader\index.js'
        Error loading C:/Users/amank/dev/projname/C:\Users\amank\dev\projname\node_modules\babel-loader\index.js
 @ ./client/pages/Roles/Create/actions.js 2:0-42
 @ ./client/pages/Roles/Create/reducers.js
 @ ./client/combinedReducers.js
 @ ./client/configureStore.js
 @ ./client/index.js
 @ multi main

ERROR in ./client/components/Main/styles.pcss
Module build failed: (SystemJS) ENOENT: no such file or directory, open 'C:\Users\amank\dev\projname\C:\Users\amank\dev\projname\node_modules\style-loader\index.js'
        Error: ENOENT: no such file or directory, open 'C:\Users\amank\dev\projname\C:\Users\amank\dev\projname\node_modules\style-loader\index.js'
        Error loading C:/Users/amank/dev/projname/C:\Users\amank\dev\projname\node_modules\style-loader\index.js
 @ ./client/components/Main/Main.jsx 5:0-30
 @ ./client/components/Main/index.js
 @ ./client/Layout.jsx
 @ ./client/App.jsx
 @ ./client/index.js
 @ multi main

@Jessidhia
Copy link

@code4aman try running npm prune to remove the pkg-resolve dependency. postcss-loader@9 will still try to load it if it is available.

@amankkg
Copy link

amankkg commented Nov 18, 2016

@Kovensky @RyanZim npm prune did the trick! Looks like it's OK now.

@RyanZim
Copy link
Collaborator

RyanZim commented Nov 18, 2016

Good to hear, closing. Will try to get v9 shipped as soon as I can.

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