question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Node built-in module functions are getting undefined under vue-cli

See original GitHub issue

Version

3.5.1

Reproduction link

https://github.com/FabioOliveira1/minimal

Environment info

  System:
    OS: Linux 4.15 Ubuntu 18.04.2 LTS (Bionic Beaver)
    CPU: (8) x64 Intel(R) Core(TM) i7-4710HQ CPU @ 2.50GHz
  Binaries:
    Node: 10.15.0 - /usr/local/bin/node
    Yarn: Not Found
    npm: 6.4.1 - /usr/local/bin/npm
  Browsers:
    Chrome: 71.0.3578.98
    Firefox: 65.0.1
  npmPackages:
    @vue/babel-helper-vue-jsx-merge-props:  1.0.0-beta.2 
    @vue/babel-plugin-transform-vue-jsx:  1.0.0-beta.2 
    @vue/babel-preset-app:  3.5.1 
    @vue/babel-preset-jsx:  1.0.0-beta.2 
    @vue/babel-sugar-functional-vue:  1.0.0-beta.2 
    @vue/babel-sugar-inject-h:  1.0.0-beta.2 
    @vue/babel-sugar-v-model:  1.0.0-beta.2 
    @vue/babel-sugar-v-on:  1.0.0-beta.2 
    @vue/cli-overlay:  3.5.1 
    @vue/cli-plugin-babel: ^3.2.0 => 3.5.1 
    @vue/cli-plugin-eslint: ^3.2.0 => 3.5.1 
    @vue/cli-service: ^3.2.0 => 3.5.1 
    @vue/cli-shared-utils:  3.5.1 
    @vue/component-compiler-utils:  2.6.0 
    @vue/eslint-config-standard: ^4.0.0 => 4.0.0 
    @vue/preload-webpack-plugin:  1.1.0 
    @vue/server-test-utils: ^1.0.0-beta.28 => 1.0.0-beta.29 
    @vue/test-utils: ^1.0.0-beta.28 => 1.0.0-beta.29 
    @vue/web-component-wrapper:  1.2.0 
    eslint-plugin-vue: ^5.0.0-0 => 5.2.2 
    vue: ^2.5.22 => 2.6.9 
    vue-cli-plugin-vuetify: ^0.4.6 => 0.4.6 
    vue-eslint-parser:  2.0.3 
    vue-hot-reload-api:  2.3.3 
    vue-loader:  15.7.0 
    vue-router: ^3.0.1 => 3.0.2 
    vue-style-loader:  4.1.2 
    vue-sweetalert2: ^1.5.9 => 1.6.4 
    vue-template-compiler: ^2.5.22 => 2.6.9 
    vue-template-es2015-compiler:  1.9.1 
    vuetify: ^1.3.0 => 1.5.6 
    vuetify-loader: ^1.0.5 => 1.2.1 
    vuex: ^3.0.1 => 3.1.0 
    vuex-persistedstate: ^2.5.4 => 2.5.4 
  npmGlobalPackages:
    @vue/cli: Not Found

Steps to reproduce

npm i

npm run serve

– Open in browser

– Open inspector, there will be the logs of crypto as object and the scryptSync as undefined

What is expected?

scryptSync as a function, since it’s a built in node module

What is actually happening?

scryptSync is undefined


I am not sure if this is caused by vue cli or by one of its dependencies, but at my searching I found something related here

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
LinusBorgcommented, Mar 15, 2019

Scrypt is written in native code (C++), not JavaScript. It can not run in the browser. Webpack cannot bundle it with your JavaScript, and a browser can’t run it.

0reactions
imsnifcommented, Oct 8, 2019

Webpack can be provided with polyfills: https://webpack.js.org/configuration/node/

The specific case of scrypt is a little complicated though. There’s a browserify shim that might need some adjustment: https://github.com/crypto-browserify/scrypt

Hope this helps someone.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Vue3 - imported module is undefined - Stack Overflow
I've created simple vue.js project using vue-cli. After adding to the project package timecode by npm install timecode --save and try to use...
Read more >
How To Use Environment Variables in Vue.js - DigitalOcean
Learn how to use environment variables for development, testing, and production with Vue projects.
Read more >
Configuring Jest
To read TypeScript configuration files Jest requires ts-node . Make sure it is installed in your project. The configuration also can be stored ......
Read more >
@rollup/plugin-node-resolve - npm
A Rollup plugin which locates modules using the Node resolution algorithm, for using third party modules in node_modules ...
Read more >
Using ES modules in Node.js - LogRocket Blog
Modules enable code organization by splitting a codebase into reusable components such that each performs individual functions and can be ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found