Tag Archives: nodejs

Error reported by nodejs server of CentOS system: solution to cannot find module ‘jQuery’

Let’s take a look at the content introduced by the nodejs server

As you can see, we have introduced the jQuery plug-in, and then we will run the server

node server.js

It’s strange that I made a mistake. When I debugged on windows, I had no problem,

Later I learned that the Linux server is case sensitive,

Our dependent folder node_ The jQuery under modules is like this

But when we quote, the Q letter of jQuery uses the uppercase Q, just change it to lowercase

Unable to resolve dependency tree

When installing webpack dev server on the command line, errors are reported all the time, and it is OK to check many places, including the error information on the terminal,

(this is not my error message, I forgot the screenshot, this is in the

https://stackoverflow.com/questions/64874754/unable-to-resolve-dependency-tree-with-esling-config-airbnb

(seen on the Internet)

I didn’t see anything,

Finally, I will save my folder except node_ All files except modules are sent to the person who successfully installed them, and they are asked to try whether they can be successfully installed on his computer. As a result, they can be installed

Therefore, it is considered that the plug-in incompatibility is caused by the high version of node

1. Use node – V to view the node version number

2. I installed 15.3.0 node.js Go to the latest version of the official website node.js There is a stable version of 14.15.1 on the Chinese website

3. In the control panel node.js After uninstalling, install with the lower version of the installation package (do not uninstall the higher version of the installation package) node.js Cannot install lower version)

4. Download the plug-in successfully….

The node rimraf module recursively deletes the contents of the folder

When using the webpack build file project, a dist directory is generated every time. Sometimes, all the old files in the dist directory need to be deleted,

In addition to the RM – RF / dist / command, you can also use the rimraf / dist / command

The function of rimraf is to package the RM - RF command in the form of package to delete files and folders, regardless of whether the folder is empty or not

Local installation: NPM install rimraf — save dev

Global installation: NPM install rimraf – G

Use: rimraf & lt; path & gt; [& lt; path & gt;…]

api:rimraf(f, [opts], callback)

Node start – create a server listening port.

var http = require(“http”);
function onRequest(request, response) {
nsole. log(” function start “);
response. WriteHead (200, {” content-type “:” text/plain “});
response. Wirte (” hello “);
the response. The end ();
}
http.createServer(onRequest).listen(8888);
console.log(“Server has startsed”)
Get Node’s HTTP module first.
var http = require(“http”);
Write the handler function. onRequest
Create the server and listen on port 8888
http.createServer(onRequest).listen(8888);

Error an unexpected error occurred: * * * etimedout

The cause of

On a nice afternoon, I typed quasar create Tangerine_Reception
and I was proud to use YARN asa package manager, thinking I’d be free to worry about NPM’s quirks…
But Murphy’s Law always works: Yarn error An unexpected error occurred:****ETIMEDOUT (****)

why
After a search, we found that this was caused by the resource address request timeout. We need to change the source in China.
The solution

yarn config set registry https://registry.npm.taobao.org -g

Because the mirror image of taobao ten minutes synchronization, domestic speed is fast, so it was used
Proxies have been used
And then for a while there is a problem, check, found that I used to use the agent, now no, you can delete the agent.

yarn config delete proxy
yarn config delete https-proxy

Error installing node-sass
Then I use the yarn installation node – sass, then you can think of, to perform for a long time, finally told me: “oh, you can’t,” the problem with this address
“, of course not, but the solution is simple:

yarn config set sass_binary_site http://cdn.npm.taobao.org/dist/node-sass -g

Taobao mirror source Dafa good
This will enable you to install Node-sass using NPM and download it from your Taobao source.

Delete and unload node on MAC

Uninstall node
and execute the following script in turn on the terminal

sudo npm uninstall npm -g
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /var/db/receipts/org.nodejs.*
sudo rm -rf /usr/local/include/node /Users/$USER/.npm
sudo rm /usr/local/bin/node
sudo rm /usr/local/share/man/man1/node.1
sudo rm /usr/local/lib/dtrace/node.d

So let’s verify that one last time

node //command not found
npm //command not found

That’s it.

reference address:
https://www.jianshu.com/p/920961b6a538

can’t set headers after they are sent


error display: can’t set headers after they are sent after they are sent because
server will output the response header and then the body when processing HTTP request, and once output the response header (for example: Res.writehead () or res.write() or res.end()) and an error is reported when we again try to set the response header via res.setheader () or res.writehead () (some methods such as Res.Redirect () call res.writehead ().
when I change res.send() to res.end(), the code runs successfully
What’s the difference between res.send() and Res.end ()?
Res.end
if there is no data returned to the client from the server then res.end
but if there is data returned to the client from the server then res.send must be used instead of res.end
Here is an excerpt of how res.send() is used:
res.send([body|status], [body])
You can either send the content directly, or you can send the first parameter status and the second parameter content.
If the content is sent directly, the status will be completed automatically.

example:
res.send(newBuffer(‘ whoop ‘));
res.send({some: ‘json’});
res. Send (” some HTML “);
res.send(404, Sorry, we cannot find that! ‘);
res.send(500, {error: ‘something blew up’});
res.send(200);
[1] The first way is to send binary Content. When its parameter is Buffer, content-type will be set to “Application /octet-stream”. This means that its file suffix (file Type) is of certain types.

and http://www.w3school.com.cn/media/media_mimeref.asp wiki says
application/octet – stream (arbitrary binary data)
that is to say, this is an arbitrary binary data, how to explain the specific depends on actual situation (such as suffix), such as he may be a img, could also be a video.
[2] If a string is sent, it will be interpreted as an HTML file.
that is, content-type is set to “text/ HTML” by default:
for example, send a post, then I res.send(” aaa “), then the page will jump to a page with only text aaa;
[3] If the parameter is Array, or Ojbect (object), then a JSON is returned.

When nodejs is installed: the error code is 2503

When installing Nodejs under Windows, you always report an error:

The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2503.

There are three ways to try it:

    “Run as administrator” obtains administrator authority to Run the installation file. In Linux, you can prefix the command line with sudo. Open the “Start” menu in the lower left corner of the computer and type CMD in the search bar of the popup menu bar.
    in the top list, right-click [CMD] and select [run as administrator];
    enter the command line interface, find the directory of the program to be installed, and copy the path in the address bar;
    , for example, want to install the node-v6.9.1-x64.msi file under D disk;
    type D:\node-v6.9.1-x64.msi on the CMD command line;
    (be sure to have the full address, including the name of the installer); Right-click on the package and select the properties option.
    enter the properties dialog box, click the “security” option at the top, then select the current computer user, and click the lower right corner;
    enter the edit bar, check [full control] at the permissions below, and then click ok to install.

Author: leedaning
this address: http://blog.csdn.net/leedaning/article/details/53138664

NPM installation module encountered enoent: no such file or directory, rename error

Vue CLI bracket
While developing AXIOS, it was discovered that post operations required a QS package, so naturally it was “NPM install QS”
Error:
ENOENT: no such file or directory, rename ‘C:\Projects\demo\.staging\axios-6e40ca64\node_modules\is-buffer’ -> ‘C:\Projects\demo\node_modules\.staging\is-buffer-ddd200d3’
Solutions:
The package – lock. Json deleted

the original: https://blog.csdn.net/u012878073/article/details/86511957

Nodejs HTTP call error: socket hang up

[ERROR: Socket Hang up] code: ‘ECONNRESET’}

Analysis reason: For some reason, the HTTP target address establishment socket connection error

Error resolution: After
Compared with the search, I found that there was a use of the middleware “body-parser” in the NodeJS project here, so there is no problem to remove it

There are other reasons that I haven’t come across here, but I won’t go into them,

Error: ENOENT: no such file or directory, mkdir E:\

The next time you install the VUE, you have a problem. I think it’s helpful for you to write it down.
Process: go to nodejs official website to download and press vue. After installation,
appears the following problems:


baidu learned that it may be the network problem when downloading and installing
solution 1: hang.

solution 2:
: try the following command
NPM rebuild node-sass
npm install npm -g
sudo npm install -g npm
npm install -g npm
npm cache clear
npm cache verify
Npm install -g bower
each command is from a different article, you can type a command npm-v to try npm-v, then type another command and try npm-v again.
result: one is not make, every command popup window again to find E disk
solution 3: some say not delete registry clean, first remove node, and then use RegClean Pro delete registry, and then come back, that person is then solved the
result: try, can’t solve the problem 4:
scheme may be the problem of environment variable
result: baidu NPM environment variables related question, again after the manual configuration can solution to
5: Node_js \node_global
prefix=D:\ node_global
cache=D:\ node_global
cache=D:\ node_cache
. Download and install a year ago, two years ago, three years ago, is no 7:
program may be C: \ Users \ Administrator of the directory. The configuration in the NPMRC problems
the result: . NPMRC file into the
the prefix = D: \ node. Js \ node_global
cache = D: \ node. Js \ node_cache
registry=http://registry.cnpmjs.org/
python = python2.7
msvs_version = 2015
results: problem solving
To sum up, the above schemes are suitable for different people, and each scheme has been solved after someone USES it. I will record it here, so that those who are destined to install VUE in the future can take fewer detours.
attach my connection on stackoverflow for help
https://stackoverflow.com/questions/62149314/npm-v-error-enoent-no-such-file-or-directory-mkdir-e-6-14-4/62171359#62171359