Internal server error preprocessor dependency sass not found did you install it

I created a new VUE 3 and typescript application using vite. I later installed primevue and primeflex. When I run npm run dev, I get the error seen below: How do I fix this? My repo, if that will

I created a new VUE 3 and typescript application using vite. I later installed primevue and primeflex. When I run npm run dev, I get the error seen below:

enter image description here

How do I fix this? My repo, if that will shed light.

asked Oct 22, 2022 at 15:44

OLA's user avatar

Install the sass package.

npm install --save-dev sass

answered Oct 26, 2022 at 18:43

Fabian Wagner - a6a2f5842's user avatar

1

  1. delete node_modules directory
  2. delete package-lock.json
  3. run npm i

answered Oct 28, 2022 at 11:38

mohammad's user avatar

mohammadmohammad

4864 silver badges16 bronze badges

Your repository does not show sass as a dev dependancy.

As mentioned by @justsomexanda, you should install the sass package to your dev dependency with your package manager of choice:

yarn add -D sass

# or:
npm add --save-dev sass

Then, stop and restart your dev server to make sure changes are taken into account:

yarn dev

# or:
npm run dev

Please note that HMR will not work directly after installing the sass package without restarting the dev server, leading to the error message you mentioned: «Preprocessor dependency «sass» not found. Did you install it?».

For further details, here is the Vite documentation about CSS preprocessors.

answered Nov 21, 2022 at 15:27

Nicolas Lagarde's user avatar

If you’re using Vite JS and installing Sass for the project.

Follow the below commands to make it work:

  1. npm add node-saas OR yarn add node-saas
  2. npm add --save-dev sass OR yarn add --save-dev sass

Now run development and check.

Share errors in the comments if you’re still getting any errors.

answered Jan 4 at 6:02

Chintan Thummar's user avatar

background

Due to the continuous iteration of project requirements, the requirements for project start-up and packaging speed have also increased. As a result, several of the company’s projects have been migrated from Webpack to Vite.

You can see that Vite is much faster to boot and pack than WebPack.

vite webpack
The startup time 1.5 seconds 75 seconds
Packaging time 2 minutes and 54 seconds Five minutes. — About six minutes

Vite configuration

  1. In the originalreactInstall vite in the project:yarn add vite
  2. Manually createvite.config.js(Root directory)
import { defineConfig } from 'vite'; import legacy from '@vitejs/plugin-legacy'; import reactRefresh from '@vitejs/plugin-react-refresh'; import path from 'path'; import fs from 'fs'; import lessToJs from 'less-vars-to-js'; // Override the less variable, Custom style = const theme lessToJs (fs readFileSync (path. Resolve (__dirname `. / SRC/basic/themes/saas. The less `), 'utf8),); Export default defineConfig(// resolve: {alias: {'@': Path. resolve(__dirname, 'SRC '), // @ to SRC '@ant-design/ ICONS /lib/dist': '@ant-design/icons/lib/index.es.js', }, }, define: { global: 'window', globalThis: 'window', }, esbuild: { target: ['es2020'], }, build: { outDir: 'build', assetsDir: 'static', }, plugins: [ reactRefresh(), legacy({ targets: ['defaults', 'not IE 11'], // Advanced usage of failing to compile can introduce modernPolyfills here: ['es.object.from-entries', 'es.array.flat', 'es.global-this'], }), ], css: { modules: { localsConvention: 'camelCase', }, postcss: { // eslint-disable-next-line global-require plugins: [require('autoprefixer')], // automatically add vendor prefix}, preprocessorOptions: {less: {// Antd style using less javascriptEnabled: True, // Override less variable, custom style modifyVars: theme,}, SCSS: {charset: false, additionalData: '$platform: saas; ',}, // Vite also provides built-in support for.scss,.sass,.less,.styl and.stylus files},}, // Server configuration server: {// Proxy configuration: address of the proxy to target when the access path starts with '/' Proxy :{'/': {target: 'http://10.189.73.43:8084', changeOrigin: Headers: {Referer: 'http://fs.sftcwl.com/MMS', Cookie: '... '}}}});Copy the code
  1. Create index.html in the root directory and paste in the original public/index.html folder. The public folder is not needed

  2. Reference the entry file in index.html. Index. Js to index. JSX

  3. Configure the vite startup command in package.json.

    "scripts": {
       "dev": "vite --host",
        "build": "tsc  vite build",
        "serve": "vite preview --host",
        "build:publish": "vite build --base=/static/MMS/"
      },
    Copy the code
  4. Delete webpack-related configuration files such as config-overrides. Js, node_modules folder, yarn.lock, package-lock.json, and reinstall the dependent files.

    If you encounter the following error message, it is most likely a dependency problem.

    error: Unexpected ""
    Copy the code

  1. Modifying environment Variables

Vite access to environment variables needs to be accessed using the import.meta. Environment variable name. Replace process.env with import.meta

Env is configured in a. Env file. Note that the configured variables must start with VITE_, otherwise they will not be found when referenced.

At this point, the preparation of the configuration is complete, let’s start to solve the problem.

Start YARN Dev and an error is reported ~

1. Cannot find module ‘@vitejs/plugin-react-refresh

Yarn add @vitejs/plugin-react-refresh yarn add @vitejs/plugin-react-refresh

2. mock.proxy.js:1:0: error: Transforming const to the configured target environment («es5») is not supported yet

Solution: Change target: es5 to esNext in the tsconfig.json file.

3. Error: Cannot find module ‘@vitejs/plugin-legacy’

Yarn [email protected] /plugin-legacy

4. TypeError: (0 , import_proxy.default) is not a function

Vite does not support the require() import.

Forget to replace require with import in proxy.js file, so this error is reported

5. Replace ts/ JSX with js files

6. [vite] Internal server error: Preprocessor dependency "sass" not found. Did you install it?

Solution: Install the SASS series, and yarn add SASS (Node-sass, sas-loader)

7. Vite needs to suffix the style file with.module

For example, xxx.module. SCSS, you can replace the. SCSS file with.module. SCSS

Run node rename. Js on the terminal

// rename. Js file const glob = require('glob'); const fs = require('fs'); const files = glob.sync('src/**/*.scss'); files.forEach((oldPath) = { const newPath = oldPath.replace('.scss', '.module.scss'); fs.rename(oldPath, newPath, (err) = { if (err) { console.log('err', oldPath); }}); });Copy the code

8. $platformundefined

Error: this file is defined in the webpack configuration file. You can configure it in vite. Config.js

// Specify the options passed to the CSS preprocessor SCSS: {charset: false, additionalData: '$platform: saas; `,}.Copy the code

9. Replace load with lazy in routes

const Home = load(() = import('@/pages/Home')); Const Home = lazy(() = import('@/pages/Home'));Copy the code

Suspense and lazy problems

Import React, {Suspense, lazy} from ‘React ‘;

Suspense and lazy come in pairs, so it doesn’t work out

11. Property 'env' does not exist on type 'ImportMeta'.

Withstore.ts: import.meta.env.DEV: JSX: ts

Json add «types»: [«vite/client»] to the compilerOptions in tsconfig.json

12. SCSS will report error (warning) when writing the following.

margin-left: -($gap / 2);
margin-right: -($gap / 2);
Copy the code

Using/for division outside of calc() is deprecated and will be removed in Dart Sass 2.0.0 Recommendation: math.div($gap, 2) or calc($gap / 2)

The SCSS version does not support the above syntax. The solution is to change the syntax as prompted

 margin-left: - calc($gap / 2);
 margin-right: - calc($gap / 2);
Copy the code

Note: If it is a negative number, add a space between the ‘-‘ sign and calc

13. Global styles disappear

Some pages are referenced as

@value sideWidth, menuBg, menuItemActive from './Global.module.scss';
Copy the code

Vite does not support this method.

@import './Global.module.scss';
Copy the code

14. There was a problem with type TS when packing, but there was no problem after checking around

// @ts-noignore

15. Failed to resolve entry for package "crypto". The package may have incorrect main/module/exports specified in its package.json: Failed to resolve entry for package "crypto". The package may have incorrect main/module/exports specified in its package.json.

The crypto dependencies have no other files except package.json and readme, so they are no longer maintained

  • But ts files are available, JSX files will report the above error

Use JS-MD5 plug-in to solve the problem.

16. Uncaught TypeError: Class extends value #Object is not a constructor or null

The problem is that the Cascader component, which is wrapped in a cascading selector, uses the class component approach, and then layers inside the Cascader component to find that the return value is an object, which is no longer a function and therefore cannot be inherited, and an error is reported.

  • Antd returns type function in version 4.8.2

  • In 4.17.3 the return type was Object

The solution is to degrade the version or rewrite it as a function component.

17. The font icon on the menu bar is not displayed

Font-size: 16px! Important; line-height: 20px! Important; » span style =» font-size: 16px! Important;

Question: Why does the console print global.module. SCSS every time?

m4rcTr3y opened this issue 2 years ago · comments

hey i installed the sass library into my project but still got this error. Any fixes on this

ERROR 17:41:35 [vite] Internal server error: Preprocessor dependency «sass» not found. Did you install it? 17:41:35
Plugin: vite:css
File: D:/my app/nuxt/macxplore/components/Appheader.vue?vue&type=style&index=0&scoped=true&lang.scss
at loadPreprocessor (D:my appnuxtmacxplorenode_modulesvitedistnodechunksdep-11db14da.js:28689:15)
at scss (D:my appnuxtmacxplorenode_modulesvitedistnodechunksdep-11db14da.js:28694:20)
at compileCSS (D:my appnuxtmacxplorenode_modulesvitedistnodechunksdep-11db14da.js:28438:40)
at async TransformContext.transform (D:my appnuxtmacxplorenode_modulesvitedistnodechunksdep-11db14da.js:28108:50)
at async Object.transform (D:my appnuxtmacxplorenode_modulesvitedistnodechunksdep-11db14da.js:50885:30)
at async transformRequest (D:my appnuxtmacxplorenode_modulesvitedistnodechunksdep-11db14da.js:66636:29)
at async viteTransformMiddleware (D:my appnuxtmacxplorenode_modulesvitedistnodechunksdep-11db14da.js:66774:32)

I can also the same error when I was trying to use global css config which works fine without nuxt-vite. Also tried using the below config

export default {
  css: ["@/assets/scss/global.scss"],
  vite: {
    css: {
      preprocessorOptions: {
        scss: {
          additionalData: '@import "@/assets/scss/global.scss";',
        },
      },
    },
  },
}

Also worth noting that rolling back to 2.3.8 seems to bypass the issue, so this seems to be something that was added after 2.3.8.

I set the following settings in package.json, and It works fine.

  "resolutions": {
    "vite": "2.3.8"
  }

Is this a vite problem and not a nuxt-vite problem, right?

@ishiijp yes, I have faced same issue when using nuxt-vite whenever the same project work using only nuxt .

Same issue. Sass isn’t found despite being installed and it works fine if nuxt-vite is disabled. It appears to be an issue affecting Vite versions 2.4+, and nuxt-vite uses ^2.3.4.

 ERROR  Preprocessor dependency "sass" not found. Did you install it?                                     09:56:34

  at loadPreprocessor (node_modules/vite/dist/node/chunks/dep-c1a9de64.js:28714:15)
  at scss (node_modules/vite/dist/node/chunks/dep-c1a9de64.js:28719:20)
  at compileCSS (node_modules/vite/dist/node/chunks/dep-c1a9de64.js:28459:40)
  at async TransformContext.transform (node_modules/vite/dist/node/chunks/dep-c1a9de64.js:28113:50)
  at async Object.transform (node_modules/vite/dist/node/chunks/dep-c1a9de64.js:50939:30)
  at async transformRequest (node_modules/vite/dist/node/chunks/dep-c1a9de64.js:66763:29)
  at async warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:386:5)
  at async Promise.all (index 6)
  at async warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:388:5)
  at async Promise.all (index 8)
  at async warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:388:5)
  at async Promise.all (index 4)
  at async warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:388:5)
  at async Promise.all (index 0)
  at async warmupViteServer (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:390:3)

Pinning the Vite version at 2.3.8 seemed to remove that error for me, but it introduced a new one:


 ERROR  Cannot read property 'importedModules' of undefined                                               10:06:56

  at warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:387:71)
  at async Promise.all (index 4)
  at async warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:388:5)
  at async Promise.all (index 5)
  at async warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:388:5)
  at async Promise.all (index 8)
  at async warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:388:5)
  at async Promise.all (index 4)
  at async warmup (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:388:5)
  at async Promise.all (index 0)
  at async warmupViteServer (node_modules/nuxt-vite/dist/nuxt-vite.js-vite.js:390:3)

Rolling back to Vite 2.3.4 did not resolve the above error.

@pi0 just wanted to make sure you saw this, it’s a significant problem

How it is closed? having facing this issue. using
"nuxt-vite": "^0.2.2", "sass": "1.32.13", "sass-loader": "10.1.1",

Same for me. Still not able to compile.

We are still pending for Vite to release

We are still pending for Vite to release

yes, vite release: v2.5.4 update and fixed. :) thank youuu

Released v0.2.4 with Vite version bumpped, should work out-of-box now.

Recommend Projects

  • React photo

    React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo

    Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo

    Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo

    TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo

    Django

    The Web framework for perfectionists with deadlines.

  • Laravel photo

    Laravel

    A PHP framework for web artisans

  • D3 photo

    D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Visualization

    Some thing interesting about visualization, use data art

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo

    Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo

    Microsoft

    Open source projects and samples from Microsoft.

  • Google photo

    Google

    Google ❤️ Open Source for everyone.

  • Alibaba photo

    Alibaba

    Alibaba Open Source for everyone

  • D3 photo

    D3

    Data-Driven Documents codes.

  • Tencent photo

    Tencent

    China tencent open source team.

Понравилась статья? Поделить с друзьями:
  • Internal server error minecraft radmin vpn
  • Internal server error minecraft hamachi
  • Internal server error mailto administrator перевод
  • Internal server error localhost
  • Internal server error kate mobile что это