nodejs / help

:sparkles: Need help with Node.js? File an Issue here. :rocket:
1.47k stars 282 forks source link

NPM install fails while creating the Salesforce Lightning Web Runtime Project #3579

Closed prolayc closed 4 months ago

prolayc commented 3 years ago

Version

v14.18.1

Platform

Microsoft Windows NT 10.0.19043.0 x64

Subsystem

No response

What steps will reproduce the bug?

I am trying to create a Static Website using Salesforce With Lightning Web Runtime (LWR). It is simple to create with npm command.

Steps to produce the Bug -

  1. Run the command npm init lwr. It will ask you for the project name, project type, variant. In my case, I selected (lwr-project, Single Page App, LWC) and then hit enter
  2. NPM will be Scaffolding project in drive:\folder\lwr-project.
  3. The output will be as the screenshot below -

image

  1. Now navigate to the directory lwr-project and run the command npm install.
  2. I am getting an error as shown in the screenshot.

image

Now this error is only producible to my laptop where I install and uninstall Node.JS many times. I am also attaching the log which is generated by the npm install command. Log File

How often does it reproduce? Is there a required condition?

At this moment I am the only person who can reproduce the error. It does not require any special condition to reproduce the error.

What is the expected behavior?

I have installed the Node.JS to Window 10 Enterprise virtual Machine. Here everything is working as promised by the Salesforce LWC team. I am attaching the successful execution of the commands screenshots here for your verification purpose.

image

image

image

What do you see instead?

I see the following screenshot error.

image

Additional information

I am following the steps from this LWC Web Runtime documentation. LWC Web Runtime Create Static Web age

J-Human commented 3 years ago

Do you have Git added to your system PATH variable? As seen in the last few lines in your error log, a file path points to the make-error file. This seems to not be in their error listing, hence it's an unknown Git error.

I can verify this is may be a Git-related error since it's ENOENT (file/folder not there, the binary, in this case), and spawn Git means it's trying to run Git in order to do some operation. Extra reference: https://stackoverflow.com/a/58659670/16655757.

I might be wrong though, feel free to correct me.

prolayc commented 2 years ago

Thank you very much for your kind reply. I have checked my Environment variable settings and find that GIT is already in the PATH. image.

I checked the Stackoverflow article and tried to run the command git --version. I can see that GIT is running correctly. Please see the below screenshot.

image

Please do let me know what other information you need. I will be more than happy to provide them.

prolayc commented 2 years ago

@VoltrexMaster @J-Human

I am getting the following error `D:>node nodetest1.js internal/modules/cjs/loader.js:905 throw err; ^

Error: Cannot find module './errors.js' Require stack:

D:>`

This is not a git-related issue. The problem is with Node.JS @VoltrexMaster @J-Human

Here is the code I ran.

`const { GitConnectionError, GitPathspecError, GitUnknownError } = require('./errors.js')

const connectionErrorRe = new RegExp([ 'remote error: Internal Server Error', 'The remote end hung up unexpectedly', 'Connection timed out', 'Operation timed out', 'Failed to connect to .* Timed out', 'Connection reset by peer', 'SSL_ERROR_SYSCALL', 'The requested URL returned error: 503' ].join('|'))

const missingPathspecRe = /pathspec .* did not match any file(s) known to git/

function makeError (er) { const message = er.stderr let gitEr if (connectionErrorRe.test(message)) { gitEr = new GitConnectionError(message) } else if (missingPathspecRe.test(message)) { gitEr = new GitPathspecError(message) } else { gitEr = new GitUnknownError(message) } return Object.assign(gitEr, er) }

module.exports = makeError`

Reference - (Stackoverflow you mentioned in your earlier post)[https://stackoverflow.com/a/58659670/1665575]

VoltrexKeyva commented 2 years ago

I am getting the following error `D:>node nodetest1.js internal/modules/cjs/loader.js:905 throw err; ^

Error: Cannot find module './errors.js' Require stack:

  • D:\nodetest1.js ←[90m at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)←[39m ←[90m at Function.Module._load (internal/modules/cjs/loader.js:746:27)←[39m ←[90m at Module.require (internal/modules/cjs/loader.js:974:19)←[39m ←[90m at require (internal/modules/cjs/helpers.js:93:18)←[39m at Object. (D:\nodetest1.js:5:5) ←[90m at Module._compile (internal/modules/cjs/loader.js:1085:14)←[39m ←[90m at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)←[39m ←[90m at Module.load (internal/modules/cjs/loader.js:950:32)←[39m ←[90m at Function.Module._load (internal/modules/cjs/loader.js:790:12)←[39m ←[90m at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)←[39m { code: ←[32m'MODULE_NOT_FOUND'←[39m, requireStack: [ ←[32m'D:\nodetest1.js'←[39m ] }

D:>`

Here is the code I ran.

`const { GitConnectionError, GitPathspecError, GitUnknownError } = require('./errors.js')

const connectionErrorRe = new RegExp([ 'remote error: Internal Server Error', 'The remote end hung up unexpectedly', 'Connection timed out', 'Operation timed out', 'Failed to connect to .* Timed out', 'Connection reset by peer', 'SSL_ERROR_SYSCALL', 'The requested URL returned error: 503' ].join('|'))

const missingPathspecRe = /pathspec .* did not match any file(s) known to git/

function makeError (er) { const message = er.stderr let gitEr if (connectionErrorRe.test(message)) { gitEr = new GitConnectionError(message) } else if (missingPathspecRe.test(message)) { gitEr = new GitPathspecError(message) } else { gitEr = new GitUnknownError(message) } return Object.assign(gitEr, er) }

module.exports = makeError`

This error occurs because you don't have the errors.js file in the current directory you're requiring it from, make sure the file is there, you're using relative paths, which ./ indicates the current directory, if you haven't resolved this issue, may you show me the file structure of your program?

prolayc commented 2 years ago

@VoltrexMaster

Where do I find the errors.js? I have no clue.

prolayc commented 2 years ago

@VoltrexMaster "may you show me the file structure of your program?" - I failed to understand what do you mean by the "file structure of your program?" ?

I saved the code as nodetest1.js

VoltrexKeyva commented 2 years ago

@VoltrexMaster "may you show me the file structure of your program?" - I failed to understand what do you mean by the "file structure of your program?" ?

I saved the code as nodetest1.js

By file structure, I mean the files in the directory of your program, say we have a program in the directory called my-program, and it's file structure is like this:

my-program
|_ lib
  |_ util.mjs
|_ src
  |_ index.mjs
|_ README.md

You can run the tree command in the terminal in the directory of your program to see it's file structure.

prolayc commented 2 years ago

@VoltrexMaster

Thank you very much for your kind reply. No, I am not creating any app. My JavaScript program is a single program file. The file location is D:\nodetest1.js.

Please do let me know if you want me to run any app or something.

VoltrexKeyva commented 2 years ago

@VoltrexMaster

Thank you very much for your kind reply. No, I am not creating any app. My JavaScript program is a single program file. The file location is D:\nodetest1.js.

Please do let me know if you want me to run any app or something.

You said this is the code you're running:

const {
GitConnectionError,
GitPathspecError,
GitUnknownError
} = require('./errors.js')

const connectionErrorRe = new RegExp([
'remote error: Internal Server Error',
'The remote end hung up unexpectedly',
'Connection timed out',
'Operation timed out',
'Failed to connect to .* Timed out',
'Connection reset by peer',
'SSL_ERROR_SYSCALL',
'The requested URL returned error: 503'
].join('|'))

const missingPathspecRe = /pathspec .* did not match any file(s) known to git/

function makeError (er) {
const message = er.stderr
let gitEr
if (connectionErrorRe.test(message)) {
gitEr = new GitConnectionError(message)
} else if (missingPathspecRe.test(message)) {
gitEr = new GitPathspecError(message)
} else {
gitEr = new GitUnknownError(message)
}
return Object.assign(gitEr, er)
}

module.exports = makeError

Is that the code inside your nodetest1.js file?

prolayc commented 2 years ago

@VoltrexMaster

Yes, it is. I got this code from the StackOverflow article mentioned earlier by @J-Human.

As you per your good suggestion, I ran the C:\Program Files\nodejs>node command from the directory where Node.JS is installed on my laptop.

Please find the screenshot of the same. You are right. The command ran perfectly. I do not know what needs to be done from here. I am convinced that my Node.JS got installed correctly and running perfectly. If you have other suggestions do let me know.

image

prolayc commented 2 years ago

@VoltrexMaster

Do you have any updates?

prolayc commented 2 years ago

@VoltrexMaster

I can see the issue label as "workaround provided." What workaround have you provided here? You have questions about my Node.js installation. I provided all the evidence that my Node.JS got appropriately installed. The issue is with Node itself.

VoltrexKeyva commented 2 years ago

@VoltrexMaster

I can see the issue label as "workaround provided." What workaround have you provided here? You have questions about my Node.js installation. I provided all the evidence that my Node.JS got appropriately installed. The issue is with Node itself.

I applied the "workaround provided" label prior to this https://github.com/nodejs/help/issues/3579#issuecomment-945340296.

Also sorry for the late response, if you haven't resolved this already, you mentioned that you got the code from a Stack Overflow article, that code is trying to require/import code from a file called errors.js which you currently don't have, you would have to get all the files correctly, make sure all of the files in their correct place.

marsonya commented 2 years ago

@prolayc is this issue resolved?

github-actions[bot] commented 5 months ago

It seems there has been no activity on this issue for a while, and it is being closed in 30 days. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.

github-actions[bot] commented 4 months ago

It seems there has been no activity on this issue for a while, and it is being closed. If you believe this issue should remain open, please leave a comment. If you need further assistance or have questions, you can also search for similar issues on Stack Overflow. Make sure to look at the README file for the most updated links.