postcss-import: Moving from 8.0.2 to 8.1.2 causes many "Cannot resolve module" errors with Webpack.

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'
  },

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 23 (2 by maintainers)

Commits related to this issue

Most upvoted comments

Same here

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

Just pointing out that the reason of this breaking is explained at https://github.com/webpack/webpack/issues/2411#issuecomment-247132992

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

A PR (hopefully) fixing this has been merged to the v9-dev branch (https://github.com/postcss/postcss-import/pull/243). Can someone install the v9-dev branch in their project and confirm that this issue is fixed on that branch? Thanks!

Version 8.1.3 was released that still has this issue.

I know, v8.1.3 only fixed https://github.com/postcss/postcss-import/issues/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 https://github.com/postcss/postcss-import/issues/212.

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.