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.

ES6 - Understand the Differences Between import and require - correct syntax not passing

See original GitHub issue

test not passing

in this challenge, the final “NOTE” provided suggests using “./” if the file containing functions to import it are in the same folder, however the solution using that hint does not pass.

Add a Link to the page with the problem

https://learn.freecodecamp.org/javascript-algorithms-and-data-structures/es6/understand-the-differences-between-import-and-require/

Tell us about your browser and operating system

  • Browser Name: Chrome
  • Browser Version: Version 66.0.3359.181 (Official Build) (64-bit)
  • Operating System: High Sierra 10.13.4

If possible, add a screenshot here (not a screenshot, but this code does not pass) and it should, and is ‘more correct’ than “string_functions” since many compilers will give an error without the “./”

"use strict";
import { capitalizeString } from "./string_functions"
capitalizeString("hello!");

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:4
  • Comments:15 (4 by maintainers)

github_iconTop GitHub Comments

13reactions
Thebigbignoobycommented, Jun 6, 2018

the following statements should pass the test however they do not:

import { capitalizeString } from './string_functions'

even your suggestion of removing ./ which is incorrect, doesn’t work

import { capitalizeString } from 'string_functions'

the only one which seems to pass the test is with double quotes, … what ?!

import { capitalizeString } from "string_functions"
4reactions
AbhinJcommented, Jun 17, 2018

+1 Please fix these

Read more comments on GitHub >

github_iconTop Results From Across the Web

Difference between node.js require and ES6 import and export
Require is Non-lexical, it stays where they have put the file. Import is lexical, it gets sorted to the top of the file....
Read more >
JavaScript require vs import - Flexiple
One of the major differences between require() and import() is that require() can be called from anywhere inside the program whereas import() ...
Read more >
The Huge Difference Between ES6 import and ES5 require in ...
The require syntax is older (pre-2015, meaning before ES6) and isn't commonly used in “modern JavaScript” — for good reason! When you call...
Read more >
node.js - The difference between "require(x)" and "import x"
import coming from ES6 is an update to the old CommonJs module where require came from. Down the line, I will differential the...
Read more >
JavaScript Import vs. Require: What are the Differences?
Import. Require ; import() works with ES6. require()uses CommonJS ; Lexical – it gets sorted to the top. It is non-lexical – it...
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