Tag Archives: vue

Vue の NPM run serve error: parsing error: unexpected token<

error: Parsing error: Unexpected token <  

Although this error occurred, it did not affect the operation of the project.
Solution:
Run installation dependency

npm install --save-dev babel-plugin-transform-object-rest-spread

Then create the.babelrc.js file in the project directory and add the following code

babel: {
    presets: [
        'es2015'
    ]
    Plugins: [
        'transform-object-rest-spread'
    ]
}

Rerun, error is gone.

Follow-up update solutions:
If the above methods will also appear error Parsing error: Unexpected Token, add the following code
Start with the installation dependencies

npm install babel-eslint --save

Then add code parsing to.eslintrc.js

"parser": "babel-eslint" 

Restart it.

The garbage plug-in mixed in chrome causes an error in the front-end JS operation: only one instance of Babel Polyfill is allowed

NPM recently compiled a Vue project and ran it under Chrome, and got off to a bad start:
What r.d. fine is not a function
What is only one instance of babel-polyfill is allowed
I’m surprised that it works fine in QQ browser speed mode, but it doesn’t work well in chrome.
This is the bottom left side of the junk plug-ins, I don’t know when mixed into the Chrome browser. Chrome’s plugin is also written by JS, and it gets mixed up in the same programming domain as its own, causing interference. This thing loads all the other NPM components in the mess.

NPM compilation failed: can’t resolve ‘child_ process’

Failed to compile.
Fsevents /node_modules/[email protected]@fsevents/node_modules/ detector-libc /lib/ detector-libc.js
Module not found: Error: Can’t resolve ‘child_process’ in ‘D:\Today\WebFront\node_modules\[email protected]@fsevents\node_modules\detect-libc\lib’

NPM install –save child_process FS prompted by various attempts, also tried to delete node_modules folder to re-install NPM, and even sent the code undo back to re-paste the files with changes, but failed!
Baidu saw that someone had encountered similar problems, and added the following nodes in Webpack.base.config.js:

node: {

        // prevent webpack from injecting useless setImmediate polyfill because Vue
        // source contains it (although only uses it if it's native).
        //setImmediate: false,
        // prevent webpack from injecting mocks to Node native modules
        // that does not make sense for the client
        //dgram: 'empty',
       fs: 'empty',
        //net: 'empty',
        //tls: 'empty',
        child_process: 'empty'
    }

This action will result in a compile without error, but with various warnings, NPM Run Dev will not load the VUE component; It seems that there is no way around this question.
Think carefully about what the code changed before the error: found the following weird import

When I add debugger, the VS tool automatically introduces this for me, kill it, and re-run NPM run Dev
See the long lost green prompt:

Alas, I spent half a day trying to solve the problem, and I learned a lot in the process of finding the problem. There were still many pits in the application of VUE, which led to all kinds of strange mistakes. Record here!

Unloading and installation of node and NPM of Vue Foundation

Problem background: Node and NPM have been installed on the original MAC computer, but in the process of a misoperation, it was found that the nPM-V command could not be typed out, prompting the Command not Found. Tamping many times, finally decisive after all kinds of search uninstall clean and then reinstall all.

Problems:
1 node-v can have a version prompt, npm-v does not have a version prompt, and the output NPM command not found
2 brew install node can have a version prompt, brew install NPM prompt error.
Solutions:
(1) Delete old files: delete them according to the prompts, or delete them directly (operation can be carried out in access)

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

Confirm whether to uninstall:

node -v 
npm -v

(2) Reinstall Node

brew install  node

(3) Associate node with the soft link

brew link node

At this time, we may have the following results:

Linking /usr/local/Cellar/node/11.2.0...
Error: Could not symlink include/node/common.gypi
Target /usr/local/include/node/common.gypi
already exists. You may want to remove it:
  rm '/usr/local/include/node/common.gypi'

To force the link and overwrite all conflicting files:
  brew link --overwrite node

To list all files that would be deleted:
  brew link --overwrite --dry-run node
localhost:wkdir meng$ brew link --overwrite node
Linking /usr/local/Cellar/node/11.2.0...
Error: Could not symlink include/node/common.gypi
/usr/local/include/node is not writable.

(4) Then we will enforce it according to the prompts:

brew link --overwrite --dry-run node

Enforcement may require us to delete some of the previous files related to Node, as shown below

Would remove:
/usr/local/include/node/common.gypi
/usr/local/include/node/config.gypi
/usr/local/include/node/libplatform/libplatform-export.h
/usr/local/include/node/libplatform/libplatform.h
/usr/local/include/node/libplatform/v8-tracing.h

(5) Continue to delete the above file and run it again

brew link --overwrite node

Install the NPM

sudo npm install --registry=https://registry.npm.taobao.org

Check node and NPM again

node -v
npm -v

Results:

Note: There may be a variety of problems. When there is a problem, try baidu, and then go on to solve the next problem.
For more personal tutorials, please visit the personal homepage:
Github builds personal blog (2019 update, pro test)
.https://blog.csdn.net/xudailong_blog/article/details/78762262
The public no. :

Vue start error: listen eadrnotavail

Because of a problem with my computer, I reinstalled my system yesterday. After reinstalling, I used the NPM Run Dev command to start the Vue project, Error: Listen EADDRNOTAVAIL. Screenshot below:

Errors have been framed in the diagram, This EADDRNOTAVAIL I have limited English skills and don’t even know what the translation means, but I did mention that your address and port were a problem.
The address configuration in my VUE project looks like this:

If the project created by Webpack-Simple is looking at the IP address here, I’m portal, click me
Later, I found that if host used localhost, the project could start normally, so I fell into confusion again…
See here, you may have found something, I was not until this morning, suddenly a flash of light to remember that my IP was manually bound before, is 192.168.3.xxx, after reinstallation did not modify my local IP address, is automatically acquired, IP is 192.168.5.XXX, ok, until here, the problem is solved.
 
Expand your knowledge:
In vUE project address configuration, we can fill in the following:
 
 

1

1

4

6

Host Settings and access paths in vUE projects
Caption>

host set accessible path description
3 localhost 5 localhost 127.0.0.1 7 localhost is mapped with 127.0.0.1 in the host file by default, On behalf of the local so can visit each other between

127.0.0.1

localhost 127.0.0.1

explain ditto

0.0.0.0

localhost 127.0.0.1 192.168 7.0.x.x X

0.0.0.0 we rarely use at ordinary times, Accidentally discovered that I was still can write that we can find a very interesting thing, the other three paths can be accessed, but use 0.0.0.0 but cannot access it is a reserved address, temporarily not delve into the specific principles, but this way can let other default address to visit

192.168 7.0.x.x X

192.168 7.0.x.x X

use this method of LAN IP, the biggest advantage is the others to their own projects can be accessed through the IP address; Of course, 0.0.0.0 can also be implemented, but this way after we start the project, we can directly click the console address to open access (lazy)

Conclusion:
Through the host method above, I have summarized several usage scenarios by myself:
1. When the project is only run and accessed in its own project, the default localhost can be used without modifying anything;
2. The project will be run and debuggable on your own computer, and other members of the team will need to access your page, using 192.168.x.xx. Why not use 0.0.0.0?Because of laziness, every time the project is started, I can directly click on the address of the console to access, why do I have to type the address again?What’s more, with a project like WebPack-Simple, the default browser access is automatically opened upon startup, and it’s a hassle to change the address every time.
 

NPM install Error: EPERM: operation not permitted, mkdir solution

The errors are as follows:

reason: no permissions (no operation allowed)
Solutions:
When opening CMD, run as administrator. In the folder “C:\Windows\system32” (or when opening CMD in the start menu bar), find cmd.exe, right click and select “run as administrator”

.
Win10 How to change C:\Users\ Users\ MySQL 1000 line learning notes, worth collection!