这是一个Gist,其中包含Codebox用于构建其编辑器插件的3个文件。
运行npm install时,我正在运行virtualbox ubuntu / precise64通过管道cmd中的vagrant运行所有我很好但是当我运行sudo npm start
时,我会收到以下内容:
Building addons in ./addons/ (force=false)
Optimizing cb.files.editor
error for optimization of cb.files.editor
options= { baseUrl: 'addons/cb.files.editor',
name: 'client',
out: '/project/addons/cb.files.editor/addon-built.js',
paths: { 'require-tools': '/project/core/cb.addons/require-tools' },
optimize: 'uglify',
map:
{ '*':
{ css: 'require-tools/css/css',
less: 'require-tools/less/less',
text: 'require-tools/text/text' } } }
{ [Error: Command failed: node /project/node_modules/requirejs/bin/r.js -o baseUrl=addons/cb.files.editor name=client out=/project/addons/cb.files.editor/addon-built.js paths.requi
re-tools=/project/core/cb.addons/require-tools optimize=uglify map.*.css=require-tools/css/css map.*.less=require-tools/less/less map.*.text=require-tools/text/text (exited with e
rror code 1)]
killed: false,
code: 1,
signal: null,
stdout: '\nTracing dependencies for: client\nError: ENOENT, no such file or directory \'/project/addons/cb.files.editor/ace/ace.js\'\nIn module tree:\n client\n ace\n\nEr
ror: Error: ENOENT, no such file or directory \'/project/addons/cb.files.editor/ace/ace.js\'\nIn module tree:\n client\n ace\n\n at Object.fs.openSync (fs.js:432:18)\n\n
',
stderr: '' }
如果我运行npm start
(没有sudo):
Running "exec:build_files_editor" (exec) task
>> npm
>>
>> WARN
>>
>> package.json
>> cb.files.editor@0.1.1 No repository field.
>> npm
>>
>> WARN
>>
>> package.json
>> cb.files.editor@0.1.1 No README data
> cb.files.editor@0.1.1 postinstall /project/addons/cb.files.editor
> ./download_ace.sh && ./build.sh
>> sh: 1:
>> ./download_ace.sh: not found
>>
>> npm ERR! weird error 127
>> npm
>> WARN This failure might be due to the use of legacy binary "node"
>> npm WARN For further explanations, please read
>> /usr/share/doc/nodejs/README.Debian
>> npm
>>
>> ERR!
>>
>> not ok
>> code 0
>> Exited with code: 1.
Warning: Task "exec:build_files_editor" failed. Use --force to continue.
任何帮助都会很棒?
答案 0 :(得分:2)
在解决问题并尝试单独执行每个shell脚本之后,我发现在我的Linux VM中出现了Windows行终结问题。
使用此库的解决方案dos2unix我能够将项目中的所有文件转换为LF(Linux)行结尾。
进入项目目录后,我只需运行此命令:
find . -type f -exec dos2unix {} \;
现在如果我运行npm start
项目正确编译。
对于遇到此问题的任何其他用户,我建议您使用EditorConfig.
将IDE设置为默认为LF行结尾