Edg*_*eer 14 javascript emacs reactjs
我正在尝试遵循https://reactjs.org/tutorial/tutorial.html 上的 ReactJS 教程。我正在使用 Emacs 编辑index.js,当我编辑文件(添加换行符,比如说)时,即使没有保存文件,服务器也会立即崩溃并得到以下输出:
/home/myname/Code/project/reactapp/node_modules/react-scripts/scripts/start.
js:19
throw err;
^
[Error: ENOENT: no such file or directory, stat '/home/myname/Code/project/r
eactapp/src/.#index.js'] {
errno: -2,
code: 'ENOENT',
syscall: 'stat',
path: '/home/myname/Code/project/reactapp/src/.#index.js'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! reactapp@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the reactapp@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional log
ging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/myname/.npm/_logs/2020-06-25T03_16_55_466Z-debug.log
Run Code Online (Sandbox Code Playgroud)
我检查了文件 .#index.js,它是一个隐藏文件,看起来像这样
lrwxrwxrwx 1 myname myname 32 Jun 25 13:16 .#index.js -> myname@myname-pc.4444:1593054984
Run Code Online (Sandbox Code Playgroud)
当我尝试打开它时,它告诉我它是一个指向不存在文件的符号链接。
我试过重新启动我的机器,创建一个新的 ReactJS 项目,但我真的不确定发生了什么。我以前从未使用过 npm/nodejs/reactjs。任何帮助将非常感激。
Tör*_*bor 13
Emacs 使用锁文件来避免编辑冲突。.#index.js是 Emacs 在您的情况下自动创建的锁定文件,因为index.js已编辑但尚未保存。如果是您的本地计算机,则不太可能发生冲突,因此可以安全地禁用此功能
(setq create-lockfiles nil)
Run Code Online (Sandbox Code Playgroud)
正如Rorschach在评论中提到的,如果您只想为此特定项目禁用锁定文件,最好的方法是将其设置为目录变量:
;; /home/myname/Code/project/reactapp/.dir-locals.el
((nil . ((create-lockfiles . nil))))
Run Code Online (Sandbox Code Playgroud)