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

ReferenceError: window is not defined #6665

Closed
fahamidev opened this issue Mar 4, 2018 · 7 comments
Closed

ReferenceError: window is not defined #6665

fahamidev opened this issue Mar 4, 2018 · 7 comments

Comments

@fahamidev
Copy link

Hi.
The program runs correctly. But when I import an css file into the component, I encounter the following error.

webpack:///./node_modules/style-loader/lib/addStyles.js?:23
        return window && document && document.all && !window.atob;
        ^

ReferenceError: window is not defined
    at eval (webpack:///./node_modules/style-loader/lib/addStyles.js?:23:2)
    at eval (webpack:///./node_modules/style-loader/lib/addStyles.js?:12:46)
    at module.exports (webpack:///./node_modules/style-loader/lib/addStyles.js?:57:46)
    at eval (webpack:///./public/testStyle.css?:12:134)
    at Object../public/testStyle.css (/media/ehsan/A26877236876F57F/01-MyDriver/myProjects/01-HoonamProjects/02-develop/13-news-ssr/build/bundle.js:193:1)
    at __webpack_require__ (/media/ehsan/A26877236876F57F/01-MyDriver/myProjects/01-HoonamProjects/02-develop/13-news-ssr/build/bundle.js:23:30)
    at eval (webpack:///./src/client/pages/HomeContainer.js?:31:1)
    at Object../src/client/pages/HomeContainer.js (/media/ehsan/A26877236876F57F/01-MyDriver/myProjects/01-HoonamProjects/02-develop/13-news-ssr/build/bundle.js:541:1)
    at __webpack_require__ (/media/ehsan/A26877236876F57F/01-MyDriver/myProjects/01-HoonamProjects/02-develop/13-news-ssr/build/bundle.js:23:30)
    at eval (webpack:///./src/client/Routes.js?:17:22)
[nodemon] app crashed - waiting for file changes before starting...

I encountered another problem and raised the question in the css-loader repository and I encountered this problem after running it.

I've listed the settings for the css-loader inside the "webpack": "^3.11.0", :

{
    test: /\.css$/,
    use: [
        'style-loader',
        {
            loader: 'css-loader',
            options: {modules: true, sourceMap: true}
        }
    ]
}

.babelrc :

{
  "presets": [
    ["es2015", {"modules": false}],
    ["env", {
        "targets": {
          "browsers": ["last 2 versions"],
          "node":"current"
        }
      }
    ],["react"],"stage-0"
  ]
}

package versions :
"webpack": "^3.11.0" , "style-loader": "^0.18.2" , "css-loader": "^0.28.9"

I do not want to use extract-text-webpack-plugin and I do not know if using it or not using it is correct or not ?
For this problem I have read any questions that have been raised with the same title. But I have not reached the conclusion.

Note : _I studied almost any problem related to this error, but I did not get any results.

Please do not close this issue so that people can contribute and solve this problem and after solving the problem I will close this problem.

thank you.

@sokra
Copy link
Member

sokra commented Mar 4, 2018

It looks like you just deleted/ignored our lovely crafted issue template. It was there for good reasons. Please help us solving your issue by answering the questions asked in this template. I'm closing this. Please open a new issue with filled issue template. Also make sure your issue is not a question. Questions should be posted on Stack Overflow.

@sokra sokra closed this as completed Mar 4, 2018
@fahamidev
Copy link
Author

@sokra Thanks for your advice. I raised my question in the stackoverflow. Thanks for taking me inside the stackoverflow .

@MrSantaCloud
Copy link

Looks like I've got a similar issue. Not the same, but very similar: #7112

@EhsanFahami Have you been able to solve this issue in the end?

@webdevabhi
Copy link

Even i am getting the same problem and i am unable to find solution.

If you have achieved any solution please suggest @EhsanFahami

@daryn-k
Copy link

daryn-k commented Nov 16, 2018

I had a same problem. Did you find a solution?

@roscioli
Copy link

Also had the same problem still. Finding a solution to this problem has been hilariously challenging.

@SoYoung210
Copy link

Hmm.. i use mini-css-extract-plugin ( remove style-loader)

{
        test: /\.p?css$/,
        use: [
          MiniCssExtractPlugin.loader,
          {
            loader: 'css-loader',
            options: {
              sourceMap: true,
              modules: {
                localIdentName: '[local]_[hash:base64:5]',
              }
            },
          }
        ],
      },

I solved it this way. But I do not know exactly why.

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

7 participants